Skip to content

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

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

fix(requestflag): preserve CLI precedence for inner flags#116
sylvesterkaczmarek wants to merge 2 commits 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.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 20, 2026 19:35
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
@markstuart-oai
markstuart-oai force-pushed the fix/inner-flag-stdin-precedence branch from 26ef370 to 0dfa7a8 Compare September 6, 2026 01:13
@markstuart-oai

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-06T07:58:43.767253Z 65a9973 New commits
🔒 Security Review Completed 2026-09-06T08:00:19.725647Z 65a9973 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Security review completed. No security issues were found in this pull request.

Reviewed commit: 0dfa7a8a3a

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0dfa7a8a3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 111 to +112
func (f *InnerFlag[T]) IsSet() bool {
return false
return f.hasBeenSet

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep set state scoped to the current array element

When a repeatable array-of-objects flag creates a second element, an inner flag used on the first element remains globally set. For example, after setting context-management.compact-threshold on the first entry and starting a second entry with another context-management.type, piped context_management.compact_threshold is now skipped because applyStdinDataToFlags checks IsSet() before innerFieldIsSet() can see that the trailing element lacks the field. This regresses the existing per-trailing-element merge behavior; track explicit state per element or retain the innerFieldIsSet decision for array-backed inner flags.

AGENTS.md reference: AGENTS.md:L15-L18

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 65a9973. Inner flags now check per-element outer state before the generic IsSet() gate, so stdin can fill an unset field on a later array element without overriding an explicitly set field on that element. Added a two-element regression; focused requestflag tests pass.

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.

2 participants