fix: accept comma-separated values on deployment target and scope flags - #692
Draft
NickJosevski wants to merge 1 commit into
Draft
fix: accept comma-separated values on deployment target and scope flags#692NickJosevski wants to merge 1 commit into
NickJosevski wants to merge 1 commit into
Conversation
`--deployment-target "ABC,XYZ"` was sent to the server as a single target name because the flag is a pflag StringArray, while its legacy aliases (`--target`, `--specificMachines`) are StringSlice and already split on commas. Expand comma-separated values for the environment, tenant, tenant-tag and target flags on `release deploy` and `runbook run`, so the comma form matches the repeat-the-flag form. Values that can legitimately contain a comma (--variable, --skip, package/git-resource specs) are left alone. Fixes #556 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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 #556
Root cause
--deployment-targetis declared as a pflag StringArray, which does not split on commas:pkg/cmd/release/deploy/deploy.go:173—flags.StringArrayVarP(&deployFlags.DeploymentTargets.Value, ...)Its legacy aliases are registered as StringSlice, which does split on commas:
pkg/util/pflagaliases.go:39—flags.StringSlice(alias, nil, ""), used byAddFlagAliasesStringSlicepkg/cmd/release/deploy/deploy.go:78—FlagAliasSpecificMachines = "specificMachines" // octo wants a comma separated list ... but CSV also works because pflag does it for freeSo today
--specificMachines "ABC,XYZ"and--target "ABC,XYZ"both work, but the primary--deployment-target "ABC,XYZ"sends the literal stringABC,XYZto the server, producingUnable to locate deployment target(s) named 'ABC,XYZ'. The bug is an inconsistency between aflag and its own aliases, not a missing feature.
What changed
executionscommon.ExpandCommaSeparated— splits each entry on commas, trims surroundingwhitespace, drops blanks, preserves order and duplicates. Nil in, nil out.
deployRunandrunbookRunto:--environment,--tenant,--tenant-tag,--deployment-target/--run-target,--exclude-deployment-target/--exclude-run-target.Deliberately not applied to
--variable(values are arbitrary text),--skip(step names),--package/--git-resource(structured specs),--deployment-freeze-name, or--runbook-tag.The repeat-the-flag form is unchanged, so existing scripts keep working. Expansion happens before
optionsis built, so the interactive backfill intoresolvedFlagsandflag.GenerateAutomationCmdsee the already-split values;GenerateAutomationCmdemits[]stringas one
--flag 'value'per element (pkg/util/flag/flag.go:77-84), so the echoed automationcommand stays correct and re-runnable —
--deployment-target 'ABC,XYZ'in becomes--deployment-target 'ABC' --deployment-target 'XYZ'out.Test evidence
go build ./...— clean.go test ./pkg/...— 64 packagesok, 0 failures.New tests:
TestExpandCommaSeparated(pkg/executionscommon/executionscommon_test.go) — comma form,repeated form, mixed form, values containing spaces, whitespace trimming around the comma,
tenant-tag canonical values, blank entries, nil.
release deploy accepts comma-separated targets and environments; untenanted— asserts thewire request carries
SpecificMachineNames: ["first Machine", "second Machine", "third Machine"]from
--deployment-target "first Machine, second Machine" --deployment-target "third Machine".release deploy accepts comma-separated tenants and tenant tags; tenanted.runbook run accepts comma-separated environments and targets.Open questions / options
1. Scope — this one flag, or the whole multi-value execution flag set?
--deployment-target: smallest blast radius, but leaves--environment "dev,test"still broken while
--env "dev,test"works, which is the same bug wearing a different hat.--variableand--skip: consistent, but actively harmful —--variable "Note:a,b"would silently become two malformed variables.Recommendation: keep this. Four of the five (
--environment,--tenant-tag, and bothtarget flags) already accept CSV through their own legacy aliases, so this removes an
inconsistency rather than inventing new parsing.
--tenanthas no alias and is the one genuinelynew behaviour — included because splitting environments but not tenants would be arbitrary.
Happy to drop
--tenantif reviewers prefer strict "alias precedent only".--runbook-tagwas left out (no legacy alias, selects runbooks rather than deployment scope) —flagging it since it is shaped exactly like
--tenant-tagand could reasonably be included.2. Values that legitimately contain a comma.
A target/environment/tenant named
Web, Prod, or a tenant tag whose tag name contains a comma,can no longer be passed to these flags at all — there is no escape hatch. Options:
--environment/--tenant-tag/the target flags the aliases already behaved this way, so the regression surface is
--tenantplus users who were passing commas through the primary flag names.
--deployment-target 'Web\, Prod'), mirroring the escapingrelease create --packagealready does for colons. Costs a documented syntax users must learn.StringSliceinstead of a helper. Gets CSV-quoting for free(
--deployment-target '"Web, Prod",Other') viaencoding/csv, but the quoting is obscure,it changes
--helptype display fromstringArraytostrings, and it silently reinterpretsany existing value containing a quote character.
Recommendation: ship as-is, and add escaping later only if a real customer hits a comma in a
name. Worth a reviewer's call since it is technically a breaking change for such names.
🤖 Generated with Claude Code