Skip to content

Conversation

tothszabi
Copy link
Contributor

Checklist

Version

Requires a PATCH version update

Context

There is an issue with run_if propagation when there is an embedded bundle mixed with steps inside a step bundle. Here is a rough example:

step_bundles:
  A:
    steps:
    - bundle::B: {}
    - script@1: {}
  B:
    run_if: '{{ getenv "SOME_ENV" | ne "1" }}'
    steps: 
    - script@1: {}
workflows:
  A:
    steps:
    - bundle::A: {}

Using the above example, what happens is that the run_if statement from the B bundle gets inherited by the script inside the A bundle. This is incorrect as only the steps inside the B bundle should inherit the bundle's run_if statement. The A bundle has no run_ifs specified so the A bundle's script step should have no run_if statement.

We are using a recursive function to resolve all of the step bundles as there could be embedded bundles inside a bundle. The embedded bundles should inherit the parents run_if statements so we pass the so far collected run_if statements to this recursive function as we iterate over the embedded items. The Go slice is a value type from the outside but actually it wraps a pointer to the actual data inside. So passing it around and adding items to it will update all of the slices internal data storage as there is only a single one backing every value type. That is why the first embedded step bundle's run_if collection was carried over to the next step item.

The solution is to make a hard copy of the run_ifs slice which will be passed to the recursive function.

@tothszabi tothszabi force-pushed the step-bundle-run-if-fix branch from dc1b9bb to fd4247c Compare July 21, 2025 13:30
@tothszabi tothszabi force-pushed the step-bundle-run-if-fix branch from fd4247c to fa7825a Compare July 21, 2025 14:22
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewWorkflowRunPlan(tt.modes, tt.targetWorkflow, tt.workflows, tt.stepBundles, tt.containers, tt.services, tt.uuidProvider)
got, err := NewWorkflowRunPlan(tt.modes, tt.targetWorkflow, tt.workflows, tt.stepBundles, tt.containers, tt.services, (&MockUUIDProvider{}).UUID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The uuid provider was the same for all of the tests so I removed them from there.

@godrei godrei merged commit e0ef93e into master Jul 29, 2025
8 checks passed
@godrei godrei deleted the step-bundle-run-if-fix branch July 29, 2025 07:08
@godrei godrei mentioned this pull request Jul 29, 2025
2 tasks
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