Repository navigation
Add CEL-backed when conditions - #2689
Conversation
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
Dependency Review✅ No vulnerabilities or license issues found.Scanned Files
|
Resource Changes Found for
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds CEL-based condition support to parsing and evaluation, then routes workflow, custom command, and hook ChangesCEL condition support
Estimated code review effort: 4 (Complex) | ~75 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
internal/exec/workflow_utils.go (1)
379-383: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winWrap
EvaluateEerrors with step/workflow context.Every other error path in
ExecuteWorkflowuseserrUtils.Build(...).WithHint(...)for actionable messages, but these two newEvaluateEerror returns are bare — a CEL syntax/runtime error won't tell the user which step or workflow triggered it.As per path instructions: "Provide clear error messages to users, include troubleshooting hints when appropriate, and log detailed errors for debugging."
♻️ Proposed fix
- runs, err := step.When.EvaluateE(workflowConditionContext(workflow, workflowDefinition, step, commandLineStack, workflowDefinition.Env)) - if err != nil { - return err - } + runs, err := step.When.EvaluateE(workflowConditionContext(workflow, workflowDefinition, step, commandLineStack, workflowDefinition.Env)) + if err != nil { + return fmt.Errorf("workflow %q step %q: %w", workflow, step.Name, err) + }Apply the same pattern at the second call site (Lines 426-430).
Also applies to: 426-430
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/exec/workflow_utils.go` around lines 379 - 383, The new EvaluateE error returns in ExecuteWorkflow are bare and should be wrapped with the same contextual error pattern used elsewhere. Update both EvaluateE call sites in workflow_utils.go to return an errUtils.Build-based error with step/workflow context and a helpful hint, using the existing workflowConditionContext, step, and workflowDefinition data so users can tell which step or workflow triggered the CEL failure.pkg/workflow/executor.go (1)
191-197: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSame error-context gap as
internal/exec/workflow_utils.go.
result.Error = errloses which step failed. Consider wrapping with step name before returning.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/workflow/executor.go` around lines 191 - 197, The error handling in executor’s step condition evaluation drops step context when `step.When.EvaluateE(...)` fails. Update the `executor.go` logic so `result.Error` and the returned error wrap the original error with the failing step’s name/identifier, matching the context style used elsewhere (for example in `workflowConditionContext`-driven execution paths). Keep the failure path in the same `runs, err := ...` block, but ensure the wrapped error clearly indicates which `step` triggered it.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/cmd_utils.go`:
- Around line 631-635: The custom-command when gate is building its condition
context with a nil env, so env[...] lookups can fail during EvaluateE in the
custom-command execution path. Update the logic around step.When.EvaluateE and
customCommandConditionContext to resolve or pass the command environment before
evaluating the when expression, or otherwise make missing env keys safe, so
custom commands evaluate conditions consistently with workflows.
In `@NOTICE`:
- Around line 404-407: The NOTICE file is stale relative to the current
dependency set, so regenerate it from the latest go.sum rather than editing
entries manually. Re-run the notice generation script used by the repo, then
commit the updated NOTICE contents so the cel-go, antlr, go-strcase, and
playwright-go entries reflect the current dependency versions. Make sure the
regenerated output is the only change needed in NOTICE.
In `@pkg/workflow/executor.go`:
- Around line 235-269: Duplicate workflow condition context construction exists
in workflowConditionContext and the matching helper in internal/exec, so they
should be unified. Export the shared builder from this package (for example, a
BuildConditionContext helper that can take an optional env override) and update
internal/exec/workflow_utils.go to call it instead of reimplementing the same
stack-precedence and env-merge logic. Keep workflowConditionContext as a thin
wrapper or remove it once all callers use the shared helper.
---
Nitpick comments:
In `@internal/exec/workflow_utils.go`:
- Around line 379-383: The new EvaluateE error returns in ExecuteWorkflow are
bare and should be wrapped with the same contextual error pattern used
elsewhere. Update both EvaluateE call sites in workflow_utils.go to return an
errUtils.Build-based error with step/workflow context and a helpful hint, using
the existing workflowConditionContext, step, and workflowDefinition data so
users can tell which step or workflow triggered the CEL failure.
In `@pkg/workflow/executor.go`:
- Around line 191-197: The error handling in executor’s step condition
evaluation drops step context when `step.When.EvaluateE(...)` fails. Update the
`executor.go` logic so `result.Error` and the returned error wrap the original
error with the failing step’s name/identifier, matching the context style used
elsewhere (for example in `workflowConditionContext`-driven execution paths).
Keep the failure path in the same `runs, err := ...` block, but ensure the
wrapped error clearly indicates which `step` triggered it.
🪄 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: 19c046d8-68a4-4fff-b758-e475f5986e0d
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (26)
NOTICEcmd/cmd_utils.gocmd/custom_command_integration_test.gogo.modinternal/exec/workflow_utils.gopkg/condition/cel.gopkg/condition/condition.gopkg/condition/condition_test.gopkg/condition/evaluate.gopkg/datafetcher/schema/atmos/manifest/1.0.jsonpkg/datafetcher/schema/config/global/1.0.jsonpkg/datafetcher/schema/stacks/stack-config/1.0.jsonpkg/datafetcher/schema_condition_validation_test.gopkg/hooks/hook.gopkg/hooks/hooks.gopkg/hooks/step_engine_test.gopkg/schema/condition.gopkg/schema/condition_test.gopkg/utils/yaml_utils.gopkg/workflow/executor.gopkg/workflow/executor_test.gotests/fixtures/schemas/atmos/atmos-manifest/1.0/atmos-manifest.jsonwebsite/docs/cli/configuration/commands/command/steps.mdxwebsite/docs/stacks/hooks.mdxwebsite/docs/workflows/workflows/workflow/steps/index.mdxwebsite/static/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json
💤 Files with no reviewable changes (1)
- pkg/schema/condition_test.go
|
Important Cloud Posse Engineering Team Review RequiredThis pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes. To expedite this process, reach out to us on Slack in the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/exec/workflow_utils.go (1)
379-382: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider framing the condition-eval error like the rest of the workflow.
Every other early return in
ExecuteWorkflowwraps failures witherrUtils.Build(...).WithTitle(WorkflowErrTitle)plus workflow context, but a failingwhenevaluation returns the rawerrhere. When a CELwhenfails to compile/evaluate, the user gets a bare message with no workflow or step attribution. Same pattern repeats in the execution loop at Lines 427-429.Low-effort fix keeps the error experience consistent.
As per coding guidelines: "wrap errors with context using
fmt.Errorf("context: %w", err)" and use the static-error builder for complex errors.♻️ Proposed framing for the condition error
runs, err := step.When.EvaluateE(workflowPkg.BuildConditionContext(workflow, workflowDefinition, step, commandLineStack, workflowDefinition.Env)) if err != nil { - return err + return errUtils.Build(err). + WithTitle(WorkflowErrTitle). + WithContext("workflow", workflow). + WithContext("step", step.Name). + WithExitCode(1). + Err() }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/exec/workflow_utils.go` around lines 379 - 382, The `ExecuteWorkflow` condition-evaluation path returns a raw error from `step.When.EvaluateE`, unlike the rest of the workflow error handling. Update this branch, and the matching `when` evaluation in the execution loop, to wrap failures with the existing workflow error framing via `errUtils.Build(...).WithTitle(WorkflowErrTitle)` and include workflow/step context. Use the same context-bearing pattern as other early returns so CEL compile/evaluate failures are attributed consistently.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@internal/exec/workflow_utils.go`:
- Around line 379-382: The `ExecuteWorkflow` condition-evaluation path returns a
raw error from `step.When.EvaluateE`, unlike the rest of the workflow error
handling. Update this branch, and the matching `when` evaluation in the
execution loop, to wrap failures with the existing workflow error framing via
`errUtils.Build(...).WithTitle(WorkflowErrTitle)` and include workflow/step
context. Use the same context-bearing pattern as other early returns so CEL
compile/evaluate failures are attributed consistently.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ae25cebf-626c-4d57-b817-820032ade7e7
📒 Files selected for processing (5)
.github/workflows/dependency-review.ymlcmd/cmd_utils.gocmd/custom_command_integration_test.gointernal/exec/workflow_utils.gopkg/workflow/executor.go
🚧 Files skipped from review as they are similar to previous changes (3)
- cmd/custom_command_integration_test.go
- pkg/workflow/executor.go
- cmd/cmd_utils.go
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2689 +/- ##
==========================================
+ Coverage 80.65% 80.66% +0.01%
==========================================
Files 1531 1534 +3
Lines 145012 145222 +210
==========================================
+ Hits 116960 117146 +186
- Misses 21490 21493 +3
- Partials 6562 6583 +21
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Warning Release Documentation RequiredThis PR is labeled
|
|
Tip Atmos Pro
No affected stacks workflow was detected for this pull request. |
|
These changes were released in v1.223.0-rc.3. |
what
pkg/conditionto ownwhenparsing, predicate handling, CEL compilation/evaluation, runtime context, and tests.pkg/schemacompatible through aliases while wiring CEL-awarewhenevaluation into workflow steps, custom command steps, and hooks.!celconditions are supported.why
whenexpressions without replacing the existing predicate keywords.example
references
go test ./pkg/condition ./pkg/schema ./pkg/workflow ./pkg/hooks ./pkg/datafetcher;go test ./cmd -run TestCustomCommandIntegration_SkipsStepWhenConditionIsFalse;go test ./pkg/workflow/... ./pkg/hooks/...;./custom-gcl run --new-from-rev=origin/main.