Skip to content

fix(cmd): don't redefine vendored tool flag shorthands - #5496

Merged
AustinAbro321 merged 2 commits into
mainfrom
fix/vendor-flag-shorthand
Oct 27, 2026
Merged

AustinAbro321 merged 2 commits into
mainfrom
fix/vendor-flag-shorthand

Conversation

@a1994sc

@a1994sc a1994sc commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Description

zarf --log-level info tools helm list panics on main today:

panic: unable to redefine 'l' shorthand in "list" flagset: it's already used for "selector" flag

Root flags are registered whenever they are given ahead of the subcommand, and Zarf's -l (--log-level) collides with Helm's -l/--selector. -a (--architecture) collides with Helm's -a/--all the same way.

The fix drops those two shorthands for exactly those invocations. The long flags are unaffected, and zarf -l debug package deploy is unaffected because the branch only triggers when the invocation targets a vendored tool.

IsVendorCmd could not be reused: it matches only when the vendored command sits at a fixed position, so it misses the form that panics. vendorCmdInArgs scans os.Args for tools|t <vendored cmd> instead, and is used solely to decide whether to register the shorthands.

Notes for review

Split out of #5489 at a reviewer's request, since there is more than one reasonable way to do this. The alternatives I did not take:

  • Drop the shorthands unconditionally — breaks zarf -l debug … for every user.
  • Rename Zarf's shorthands — also breaking.
  • Parse flags properly before registering them (cobra TraverseChildren and friends) — the principled fix, but a much larger change to command setup for a flag collision.

The arg scan is the smallest change that keeps both sides working. Its known limit is noted in a shortcut: comment: a literal tools argument elsewhere on the line also matches, which costs only the -l/-a shorthands for that one invocation.

Testing

A table test covers vendorCmdInArgs, including the root-flag-before-subcommand form, the t alias, a non-vendored tools subcommand, and a stray tools argument.

Verified by hand against builds of both main and this branch: the command above panics on main and reaches Helm here; zarf tools helm list -l foo=bar still passes the selector through to Helm; zarf -l warn version and zarf -a amd64 version still work.

Related Issue

Relates to #5489
Fixes #5444
Relates to #5507

Checklist before merging

@a1994sc
a1994sc requested review from a team as code owners October 19, 2026 18:06
@netlify

netlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 6aff0c6
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/6ad7ddf6a1bafbdddb3de4cd

Signed-off-by: Allen Conlon <software@conlon.dev>
@a1994sc
a1994sc force-pushed the fix/vendor-flag-shorthand branch from 806b05d to 2673164 Compare October 19, 2026 18:08
@a1994sc
a1994sc added this pull request to stack #5497 October 19, 2026 18:08
@codecov

codecov Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/cmd/root.go 66.66% 2 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
src/cmd/vendor.go 48.14% <100.00%> (+14.81%) ⬆️
src/cmd/root.go 37.50% <66.66%> (+0.38%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AustinAbro321

Copy link
Copy Markdown
Member

Thanks! Should note that would fix existing issue #5444.

I think it makes sense to do a quick fix for the existing panic, I've created another issue to follow up and do this in a more clean way in the future #5507

@AustinAbro321 AustinAbro321 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good, one comment for a previous bug that interacts with this

Comment thread src/cmd/vendor.go Resolved
@github-project-automation github-project-automation Bot moved this to In progress in Zarf Oct 20, 2026
@a1994sc

a1994sc commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Thanks! Should note that would fix existing issue #5444.

I think it makes sense to do a quick fix for the existing panic, I've created another issue to follow up and do this in a more clean way in the future #5507

I did add those issues, a "fixes" and "relates to" so please let me know if that was right.

Signed-off-by: Allen Conlon <software@conlon.dev>
@a1994sc
a1994sc requested a review from AustinAbro321 October 22, 2026 16:14

@AustinAbro321 AustinAbro321 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, we'll need a more complex and complete solution at some point with #5507, but this does get rid of an existing panic. Appreciate you breaking this out

@brandtkeller brandtkeller left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@AustinAbro321
AustinAbro321 added this pull request to the merge queue Oct 27, 2026
Merged via the queue into main with commit d2830dc Oct 27, 2026
@AustinAbro321
AustinAbro321 deleted the fix/vendor-flag-shorthand branch October 27, 2026 14:32
@github-project-automation github-project-automation Bot moved this from In progress to Done in Zarf Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

zarf tools --no-color crashes with any tool that has a -l flag

3 participants