fix: push step condition to children to fix evaluation with artifacts#7627
Conversation
…on ordering When a step has both a condition (e.g., env.TEST) and artifacts, the processor creates a group stage. The group's Start action is evaluated before the Container transition that loads scoped environment variables. This caused the condition to evaluate to false (empty env var) and skip the entire step. Fix: Set the group condition to literal 'true' so it always starts, and push the step condition to each child operation via AppendConditions. Also propagate virtual group conditions to children during Flatten so nested step conditions work correctly. Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/eee39f98-f969-4696-9cdf-7a0ff62c5f45 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/eee39f98-f969-4696-9cdf-7a0ff62c5f45 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/eee39f98-f969-4696-9cdf-7a0ff62c5f45 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
|
@greptile |
Greptile SummaryThis PR fixes a bug where step conditions (e.g., A secondary pre-existing bug is also silently fixed: the old Confidence Score: 5/5Safe to merge — the fix is well-reasoned, targeted, and backed by a regression test. Only P2 findings remain. No P0 or P1 issues found. The single P2 comment flags missing test coverage for the false-condition path, which is a non-blocking improvement. The core logic is correct and the changes are minimal in scope. No files require special attention; the P2 is a test-coverage suggestion on processor_test.go. Important Files Changed
Sequence DiagramsequenceDiagram
participant P as processor.go
participant G as GroupStage (group)
participant S as ShellStage (child)
participant A as ArtifactsStage (child)
participant E as Execution Engine
Note over P,E: Step with condition:"env.TEST" + shell + artifacts
P->>G: SetCondition("true")
P->>S: AppendConditions("env.TEST")
P->>A: AppendConditions("env.TEST")
Note over A: combined: "env.TEST&&always"
P->>G: Add(S), Add(A)
E->>G: Declare (condition:"true")
E->>G: Start (always fires)
E->>S: Container transition (loads _0_TEST→TEST)
E->>S: Evaluate condition "env.TEST" — correct timing
E->>A: Evaluate condition "env.TEST&&always" — correct timing
Reviews (2): Last reviewed commit: "fix: go mod" | Re-trigger Greptile |
|
@copilot revert go.sum |
Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/6ceb86f0-3eb8-4a71-8595-cb79d51e76da Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
…#7627) * Initial plan * fix: push step condition to children instead of group to fix evaluation ordering When a step has both a condition (e.g., env.TEST) and artifacts, the processor creates a group stage. The group's Start action is evaluated before the Container transition that loads scoped environment variables. This caused the condition to evaluate to false (empty env var) and skip the entire step. Fix: Set the group condition to literal 'true' so it always starts, and push the step condition to each child operation via AppendConditions. Also propagate virtual group conditions to children during Flatten so nested step conditions work correctly. Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/eee39f98-f969-4696-9cdf-7a0ff62c5f45 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com> * test: add regression test for condition evaluation with artifacts Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/eee39f98-f969-4696-9cdf-7a0ff62c5f45 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com> * fix: improve comment explaining group condition change Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/eee39f98-f969-4696-9cdf-7a0ff62c5f45 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com> * chore: revert go.sum to original state Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/6ceb86f0-3eb8-4a71-8595-cb79d51e76da Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com> * fix: go mod Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io> --------- Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com> Co-authored-by: Vladislav Sukhin <vladislav@kubeshop.io> Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io> # Conflicts: # go.sum
Pull request description
Step conditions like
env.TESTare incorrectly evaluated asfalsewhen the step also definesartifacts, causing the entire step to be skipped.Root cause: When a step has multiple operations (shell + artifacts), the processor wraps them in a non-flattenable group. The group's
Startaction evaluates the condition before theContainertransition that loads scoped env vars (e.g.,_0_TEST=true→TEST=true). Soos.Getenv("TEST")returns""at evaluation time. With a single operation (no artifacts), the group flattens and the Container transition naturally precedes the condition check.Fix: Set the group condition to literal
"true"so it always starts, and push the step condition down to each child operation viaAppendConditions. Children evaluate the condition after their Container transition loads env vars.processor.go: Group gets"true"when step has a condition; children receive the actual condition viaAppendConditions(preserving operation-set conditions like"always"for artifacts)groupstage.go: Virtual groupFlatten()now propagates its condition to children, so nested step conditions aren't lostprocessor_test.go: Regression test verifying condition ordering with artifactsChecklist (choose whats happened)
Breaking changes
Changes
"true"and push the condition to childrenFixes