fix: preserve --variable values through interactive runbook run - #665
Open
NickJosevski wants to merge 1 commit into
Open
fix: preserve --variable values through interactive runbook run#665NickJosevski wants to merge 1 commit into
NickJosevski wants to merge 1 commit into
Conversation
Command-line --variable arguments to `octopus runbook run` were being silently dropped when the user went through the interactive prompts (without --no-prompt). Inside askRunbookPreviewVariables, the result map was rebuilt from the form preview's controls only, so any CLI variable whose name didn't match a control was discarded. The resulting runbook run fell back to the prompted variables' default values and the printed Automation Command was missing the -v args. This change extracts the variable-resolution logic into a pure helper, resolveRunbookPreviewVariables, and seeds the result map with the caller-supplied CLI variables before processing controls. Variables that do match a control are still canonicalised to the control's name (preserving the prior case-fixing behaviour). Variables without a matching control are now passed through unchanged. Adds unit tests covering: passthrough of unmatched CLI vars, canonicalisation of mismatched casing, no-prompt when CLI satisfies a required control, sensitive-variable tracking, and the still-working prompt path for unprovided required controls. A similar pattern exists in pkg/cmd/release/deploy/deploy.go around line 854; not changed here to keep this PR scoped to the reported bug. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
YuKitsune
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #582.
In interactive mode,
runbook runrebuilt the variable map from the runbook form preview only, so any--variablewhose name didn't match a preview control was dropped and the run fell back to the default value. Non-interactive runs already passed every--variablethrough.Command-line variables are now carried through unchanged, and names that do match a control are canonicalised to the control's casing so a single spelling reaches the server.
Split out of #609, where it was an unrelated change.