Skip to content

fix: dry run dispatch ctx includes synthetic release#1000

Merged
adityachoudhari26 merged 2 commits intomainfrom
dry-run-synthetic-release
Apr 15, 2026
Merged

fix: dry run dispatch ctx includes synthetic release#1000
adityachoudhari26 merged 2 commits intomainfrom
dry-run-synthetic-release

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Apr 15, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Deployment releases now include comprehensive context information (deployment, environment, and resource details) for improved release tracking and management during deployment operations.

Copilot AI review requested due to automatic review settings April 15, 2026 22:26
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

Warning

Rate limit exceeded

@adityachoudhari26 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 8 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 8 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d79cb057-5709-41c1-a0f9-3f2930d2deae

📥 Commits

Reviewing files that changed from the base of the PR and between 47f88a7 and e06a8ab.

📒 Files selected for processing (1)
  • apps/workspace-engine/svc/controllers/deploymentplan/controller.go
📝 Walkthrough

Walkthrough

A new oapi.Release object is constructed within the processTarget function for each matched agent, populated with metadata including creation timestamp, ID, target resource identifiers, variables, and version. This Release object is then attached to the oapi.DispatchContext via a new Release field.

Changes

Cohort / File(s) Summary
Release Object Construction
apps/workspace-engine/svc/controllers/deploymentplan/controller.go
Added creation and population of oapi.Release object with CreatedAt, Id, ReleaseTarget, Variables, and Version fields within processTarget, attaching it to the per-agent DispatchContext.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A release takes flight, now structured and neat,
With metadata bundled, the dispatch complete,
New fields dancing forth in the context so bright,
Each agent rejoices—their Release, oh what a sight!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a synthetic release object to the dry run dispatch context, which aligns with the code changes that construct and attach an oapi.Release object to the DispatchContext.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dry-run-synthetic-release

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

Adds a synthetic Release object to the deployment-plan dispatch context so dry-run/plan job agents can template against dispatchCtx.release similarly to real job dispatch.

Changes:

  • Construct a synthetic oapi.Release during deployment plan target processing.
  • Attach the synthetic release to oapi.DispatchContext before persisting the dispatch context blob.
Comments suppressed due to low confidence (1)

apps/workspace-engine/svc/controllers/deploymentplan/controller.go:214

  • There is existing test coverage asserting the marshalled/unmarshalled dispatch context fields for this controller, but it doesn't validate the newly-added dispatchCtx.Release behavior. Add assertions to the dispatch-context test to ensure Release is non-nil and that it contains the expected target/version/variables (and an empty encryptedVariables array) so regressions are caught.
		dispatchCtx := &oapi.DispatchContext{
			Deployment:     deployment,
			Environment:    env,
			Resource:       resource,
			Version:        version,
			Release:        release,
			Variables:      &variables,
			JobAgent:       *agent,
			JobAgentConfig: mergedConfig,
		}

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

Comment on lines +201 to +202
Variables: variables,
Version: *version,
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

oapi.Release has a required encryptedVariables field (no omitempty). Since the synthetic release leaves it unset, JSON marshalling will emit "encryptedVariables": null, which can break template usage (e.g., range over .release.encryptedVariables). Initialize it to an empty slice (and keep it non-nil) when building the synthetic release.

Suggested change
Variables: variables,
Version: *version,
Variables: variables,
EncryptedVariables: []oapi.EncryptedVariable{},
Version: *version,

Copilot uses AI. Check for mistakes.
Comment on lines +193 to +203
release := &oapi.Release{
CreatedAt: time.Now().Format(time.RFC3339),
Id: uuid.New(),
ReleaseTarget: oapi.ReleaseTarget{
DeploymentId: plan.DeploymentID.String(),
EnvironmentId: target.EnvironmentID.String(),
ResourceId: target.ResourceID.String(),
},
Variables: variables,
Version: *version,
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

The synthetic release is created inside the per-agent loop using time.Now() and a new UUID each iteration. This makes the persisted dispatch context non-deterministic across agents (and across retries) for the same plan target, which can lead to inconsistent plan outputs if templates reference release.id/release.createdAt. Consider creating the synthetic release once per target (outside the loop) and/or deriving a stable ID/timestamp from the plan/target so all agents see the same release metadata.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/workspace-engine/svc/controllers/deploymentplan/controller.go`:
- Around line 193-203: The synthetic oapi.Release literal currently omits the
EncryptedVariables field; update the Release construction (the release variable
in controller.go) to set EncryptedVariables explicitly — use an empty slice
(e.g., empty []oapi.EncryptedVariable) when there are none or populate it by
mapping existing variables to the encrypted form if an encryption/derivation
helper exists (use the same keys/IDs as Variables). Ensure you reference and set
the EncryptedVariables field on the oapi.Release struct alongside Variables and
Version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db4ac3c1-109e-4025-9e65-4c05a59bbea2

📥 Commits

Reviewing files that changed from the base of the PR and between 8d6eb2f and 47f88a7.

📒 Files selected for processing (1)
  • apps/workspace-engine/svc/controllers/deploymentplan/controller.go

Comment on lines +193 to +203
release := &oapi.Release{
CreatedAt: time.Now().Format(time.RFC3339),
Id: uuid.New(),
ReleaseTarget: oapi.ReleaseTarget{
DeploymentId: plan.DeploymentID.String(),
EnvironmentId: target.EnvironmentID.String(),
ResourceId: target.ResourceID.String(),
},
Variables: variables,
Version: *version,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Populate Release.EncryptedVariables in the synthetic release payload.

The new oapi.Release literal omits EncryptedVariables, which makes this synthetic release incomplete against the generated release shape. Please set it explicitly (empty slice if none, or derived encrypted keys when available).

Proposed fix
 		release := &oapi.Release{
 			CreatedAt: time.Now().Format(time.RFC3339),
+			EncryptedVariables: []string{},
 			Id:        uuid.New(),
 			ReleaseTarget: oapi.ReleaseTarget{
 				DeploymentId:  plan.DeploymentID.String(),
 				EnvironmentId: target.EnvironmentID.String(),
 				ResourceId:    target.ResourceID.String(),
 			},
 			Variables: variables,
 			Version:   *version,
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
release := &oapi.Release{
CreatedAt: time.Now().Format(time.RFC3339),
Id: uuid.New(),
ReleaseTarget: oapi.ReleaseTarget{
DeploymentId: plan.DeploymentID.String(),
EnvironmentId: target.EnvironmentID.String(),
ResourceId: target.ResourceID.String(),
},
Variables: variables,
Version: *version,
}
release := &oapi.Release{
CreatedAt: time.Now().Format(time.RFC3339),
EncryptedVariables: []string{},
Id: uuid.New(),
ReleaseTarget: oapi.ReleaseTarget{
DeploymentId: plan.DeploymentID.String(),
EnvironmentId: target.EnvironmentID.String(),
ResourceId: target.ResourceID.String(),
},
Variables: variables,
Version: *version,
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/workspace-engine/svc/controllers/deploymentplan/controller.go` around
lines 193 - 203, The synthetic oapi.Release literal currently omits the
EncryptedVariables field; update the Release construction (the release variable
in controller.go) to set EncryptedVariables explicitly — use an empty slice
(e.g., empty []oapi.EncryptedVariable) when there are none or populate it by
mapping existing variables to the encrypted form if an encryption/derivation
helper exists (use the same keys/IDs as Variables). Ensure you reference and set
the EncryptedVariables field on the oapi.Release struct alongside Variables and
Version.

@adityachoudhari26 adityachoudhari26 merged commit d95bf55 into main Apr 15, 2026
10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the dry-run-synthetic-release branch April 15, 2026 22:40
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