Skip to content

fix: propagate job context to argo workflow job#1103

Merged
adityachoudhari26 merged 1 commit intomainfrom
propagate-workflow-job-context
May 5, 2026
Merged

fix: propagate job context to argo workflow job#1103
adityachoudhari26 merged 1 commit intomainfrom
propagate-workflow-job-context

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented May 5, 2026

Summary by CodeRabbit

  • Tests
    • Added test coverage for job dispatch context handling to ensure proper data population and immutability of base context.

Copilot AI review requested due to automatic review settings May 5, 2026 10:22
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 116f72d2-1b85-4847-811c-50eed1a8d6dc

📥 Commits

Reviewing files that changed from the base of the PR and between 52046a1 and ff95ed3.

📒 Files selected for processing (2)
  • apps/workspace-engine/svc/http/server/openapi/workflows/setters.go
  • apps/workspace-engine/svc/http/server/openapi/workflows/workflows_test.go

📝 Walkthrough

Walkthrough

A new buildJobDispatchContext helper is added to construct a job-specific DispatchContext containing resolved JobAgent fields and merged JobAgentConfig before persistence. The dispatchJobForAgent function now uses this helper instead of persisting the base context directly.

Changes

Job Dispatch Context Enrichment

Layer / File(s) Summary
Core Helper
apps/workspace-engine/svc/http/server/openapi/workflows/setters.go
New buildJobDispatchContext function copies the base context and populates JobAgent identity fields (Id, WorkspaceId, Name, Type, Config) and JobAgentConfig from the provided runner and merged config.
Integration in Dispatcher
apps/workspace-engine/svc/http/server/openapi/workflows/setters.go
dispatchJobForAgent now marshals the job-specific context produced by buildJobDispatchContext instead of the base context before inserting the Job record.
Tests
apps/workspace-engine/svc/http/server/openapi/workflows/workflows_test.go
Two test cases verify that buildJobDispatchContext correctly populates JobAgent and merged config fields, and that it does not mutate the base context. Imports added for uuid and db package support.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • mleonidas

Poem

🐰 A context takes shape, enriched with care,
Job agents now travel with credentials to spare,
The dispatch flows true with config merged clean,
No mutations allowed—immutable, pristine!
Hops merrily through the workflows so fair. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: propagate job context to argo workflow job' directly reflects the main change: persisting a per-job DispatchContext with resolved JobAgent identity fields to workflows, enabling proper job context propagation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch propagate-workflow-job-context

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes workflow-triggered job dispatch so the persisted DispatchContext includes the resolved job agent metadata and merged job-agent config that downstream dispatchers expect. In the workspace-engine, this aligns workflow-run jobs with the existing dispatch-context contract already used by other job creation paths.

Changes:

  • Add buildJobDispatchContext to copy the base workflow dispatch context and populate JobAgent plus merged JobAgentConfig.
  • Persist the enriched per-job dispatch context instead of the base workflow-only context when inserting workflow jobs.
  • Add unit tests covering context population and the non-mutation behavior of the base context.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/workspace-engine/svc/http/server/openapi/workflows/setters.go Builds and persists a per-job dispatch context with resolved agent details/config for workflow jobs.
apps/workspace-engine/svc/http/server/openapi/workflows/workflows_test.go Adds tests for dispatch-context population and base-context immutability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adityachoudhari26 adityachoudhari26 merged commit 46b08f5 into main May 5, 2026
14 checks passed
@adityachoudhari26 adityachoudhari26 deleted the propagate-workflow-job-context branch May 5, 2026 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants