-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 1.21.0 pass through regression #872
Conversation
Codecov Report
@@ Coverage Diff @@
## master #872 +/- ##
==========================================
+ Coverage 71.48% 71.64% +0.16%
==========================================
Files 30 30
Lines 2395 2409 +14
==========================================
+ Hits 1712 1726 +14
Misses 577 577
Partials 106 106
Continue to review full report at Codecov.
|
#691 <= I looks like this PR is what caused the bug, but it doesn't revert cleanly. Which is to be expected, since it's 2 years old 😅 I'll figure this out |
I believe what happened was that the reorder args functionality here https://github.com/urfave/cli/pull/691/files#diff-9c42b524cb14ca001c61267826cbefb1R206 started accidentally pulling in args meant for pass-through commands. So like the |
There's a line in the flag re-ordering function that checks for Line 223 in 6cc7e98
|
Co-Authored-By: Sascha Grunert <[email protected]>
I'm putting this |
👋 I have returned to this PR |
… into pass-through-regression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one non-blocking comment, the rest LGTM
review ping @AudriusButkevicius / @asahasrabuddhe |
|
||
readFlagValue := false | ||
nextIndexMayContainValue := false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nextIndexMayContainValue := false | |
var nextIndexMayContainValue bool |
This is also a possibility as it would be false by default! It's fine if you don't change it too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm gonna opt against adding this into the PR - but only because I wanna merge this ASAP so that we can fix the regression 🔧
This looks good 👍 I have added a very optional change. You may or may not choose to do it 😄 |
Changes
reorderArgs
logic to ignore args that aren't defined for the command you are runningreorderArgs
for understandabilityTestCommandFlagParsing
test case that was expecting an error, to no longer expect an errorMotivation
Fixes #850
#850 caused a stop everything and fix this now P0 bug that since then taken a few dozen hours of work to fully root-out and stabilize (eg. at my dayjob). Because of that, I've been working to get a change into this package to avoid that occurring in the future.
What I'm looking for here
command_test.go
reorderArgs
as clear as possible, please let me know if I can add more context / docs / update variable names / etc.TestCommandFlagParsing
is conceptually dangerous, but in a practical sense I think it's actually safe. Please let me know if you agree or disagree? I think it's safe in a practical sense because user's shouldn't be strictly relying on this package to raise "flag provided but not defined" errors in all kinds of nuanced places.Future Work
The whole idea of argument re-ordering feels dangerous to me. Immediately after this PR I plan on investigating how I could potentially remove that functionality, without impacting the API.