Skip to content

fix: error on legacy v1-style flag alias syntax#2381

Open
happysnaker wants to merge 3 commits into
urfave:v2-maintfrom
happysnaker:fix-1103-legacy-flag-alias-syntax
Open

fix: error on legacy v1-style flag alias syntax#2381
happysnaker wants to merge 3 commits into
urfave:v2-maintfrom
happysnaker:fix-1103-legacy-flag-alias-syntax

Conversation

@happysnaker

Copy link
Copy Markdown

Fixes #1103

This changes legacy v1-style flag alias definitions like Name: "config, cfg" from a silent partial-accept path into an explicit error.

What this patch does:

  • validates Name / Aliases before registering each flag
  • rejects commas or spaces inside the primary Name field
  • rejects malformed aliases that still contain commas or spaces
  • adds a regression test that asserts App.Run() errors with a migration hint
  • updates the long-flag completion example to use v2-style Aliases explicitly

Why this shape:

  • today the old syntax looks half-working: the primary flag still exists, but the alias silently disappears
  • failing fast is easier to debug and matches the issue request for an error/warning rather than hidden misconfiguration
  • validating in each flag Apply() path keeps the behavior consistent for direct flag registration and wrappers like altsrc that delegate to the same Apply() methods

I intentionally kept the error message migration-oriented rather than trying to preserve the old behavior.

@happysnaker happysnaker requested a review from a team as a code owner July 2, 2026 04:47
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.

1 participant