fix(requestflag): preserve CLI precedence for inner flags - #116
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
fix(requestflag): preserve CLI precedence for inner flags#116sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.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.
Summary
Track whether an
InnerFlaghas been explicitly set so piped stdin data cannot overwrite a value the user already supplied on the command line.Problem
ApplyStdinDataToFlagsintentionally skips flags whoseIsSet()method reports true, preserving CLI-over-stdin precedence for ordinary request flags.InnerFlag.IsSet(), however, currently always returns false.That means a command-line value such as
--address.city cli-valuecan be applied successfully to its outer flag and then be overwritten later by piped data containingaddress.city: piped-value.Fix
InnerFlag.Setcalls with per-flag state;InnerFlag.IsSet();The state is tracked per inner flag rather than inferred from the outer flag, so setting one nested field does not incorrectly suppress stdin values for sibling fields.
Regression coverage
Added a focused regression that:
The test also asserts the inner flag now reports itself as set after a successful explicit assignment.
Validation
The branch is based directly on current upstream
main(ee92673a416c0851a5fe8907a2453db7bd450633) and contains one signed commit touching only the inner-flag implementation and its focused regression test. Full Go test execution is left to repository CI.Risk
Low. Only successfully assigned inner flags change
IsSet()from false to true; unset inner flags and ordinary request flags retain their existing behavior.