Skip to content

fix(requestflag): preserve CLI precedence for inner flags - #116

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/inner-flag-stdin-precedence
Open

fix(requestflag): preserve CLI precedence for inner flags#116
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/inner-flag-stdin-precedence

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Track whether an InnerFlag has been explicitly set so piped stdin data cannot overwrite a value the user already supplied on the command line.

Problem

ApplyStdinDataToFlags intentionally skips flags whose IsSet() 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-value can be applied successfully to its outer flag and then be overwritten later by piped data containing address.city: piped-value.

Fix

  • record successful InnerFlag.Set calls with per-flag state;
  • return that state from InnerFlag.IsSet();
  • leave unset inner flags eligible to be populated from piped data as before.

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:

  1. sets an inner field explicitly through the CLI flag path;
  2. supplies a conflicting value through piped nested data;
  3. verifies the explicit CLI value remains in the outer request object.

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.

Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 20, 2026 19:35
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