Skip to content

fix(cli-generator): stop emitting a wire-test suite where every test fails - #17568

Closed
cadesark wants to merge 1 commit into
mainfrom
cade/cli-fix-wire-test-no-pager
Closed

fix(cli-generator): stop emitting a wire-test suite where every test fails#17568
cadesark wants to merge 1 commit into
mainfrom
cade/cli-fix-wire-test-no-pager

Conversation

@cadesark

@cadesark cadesark commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Problem

generateWireTests: true currently produces a suite in which every test fails, on any spec without pagination metadata.

The generated harness pushed --no-pager on every invocation:

args.push("--base-url".to_string());
args.push(server.uri());
args.push("--no-pager".to_string());   // unconditional

But the CLI registers that flag only inside if method_has_pagination(...) (sdk/src/openapi/commands.rs). On a spec with no x-fern-pagination markers, the flag exists on zero operations, so clap rejects the whole command line before the test does anything:

unexpected argument '--no-pager' found
  a similar argument exists: '--no-retry'

That is 100% of cases, not a subset. On a real customer spec: 678 of 678 failing.

Cause

Two files on main disagree:

The gate is correct — --no-pager is only ever read as pagination.page_all && !pagination.no_pager, so on a non-paginated operation it has nothing to do. The flag was also inert in the harness: the pager can only spawn under --page-all, which no wire-test case passes. So the fix is to stop pushing it.

Why nothing caught it

seed/cli/seed.yml does declare testScript: cargo test --locked --all-features, and query-parameters-openapi:with-wire-tests is the right fixture — but that spec has 0 x-fern-pagination markers too, so the fixture is broken in exactly the same way. The coverage existed and was blind.

Verification

Reproduced and fixed end to end on the real fixture:

pnpm seed test --generator cli --fixture query-parameters-openapi --skip-scripts --local
cd seed/cli/query-parameters-openapi/with-wire-tests
cargo test --locked --all-features --test wire_test
result
before 0 passed / 2 failed
after 2 passed / 0 failed

Added a unit test asserting the harness pushes only flags the SDK registers unconditionally (--base-url, --params, --json), and verified it fails on the bug before trusting it:

AssertionError: --no-pager is pushed unconditionally; confirm the SDK registers it
on every operation: expected [ '--base-url', '--params', '--json' ] to include '--no-pager'

430 TypeScript tests passing, pnpm check clean.

Scope

Deliberately minimal so it can merge ahead of the rest — 35 lines. Split out of #17567, whose remaining fixes are unrelated to this and shouldn't hold it up.

Generated with Claude Code


Devin Review

…fails

The generated harness pushed --no-pager on every invocation, but the CLI
registers that flag only inside `if method_has_pagination(...)`. On a
spec with no pagination metadata the flag exists on zero operations, so
clap rejected the entire command line with "unexpected argument
--no-pager" -- 100% of cases, not a subset. Any customer running
`generateWireTests: true` against such a spec got a suite that could not
pass. On a real customer spec: 678 of 678 failing.

The flag was also inert: the pager only spawns under --page-all, which
no case passes. And the gate itself is correct -- --no-pager is only
ever read as `page_all && !no_pager` -- so the fix belongs on the
harness side.

Reproduced end to end on `query-parameters-openapi:with-wire-tests`:
0 passed / 2 failed before, 2/2 after. That fixture declares no
pagination either, which is why nothing caught this when the gate
landed in #17545 -- seed does run `cargo test --locked --all-features`,
it just never ran here.

Added a unit test asserting the harness pushes only flags the SDK
registers unconditionally, and verified it fails on the bug.

@nitpickybot nitpickybot 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.

AI Review Summary

Removes the unconditional --no-pager push from the wire-test harness, with a matching regression test and regenerated seed fixture. Fix is correct and minimal; the only nits are that the new test's flag-extraction regex is brittle (it only matches literal args.push("--flag".to_string()), so a flag pushed via a variable or format! would slip through) and the comment blocks are verbose for generated Rust output.

  • 🔵 2 suggestion(s)

To request another review, comment /ai-review on this pull request.

Comment on lines +367 to +369
const pushedFlags = [...rust.matchAll(/args\.push\("(--[a-z0-9-]+)"\.to_string\(\)\)/g)].map(
(match) => match[1]
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 suggestion

The regex only catches string-literal pushes of the exact shape args.push("--x".to_string()). A flag pushed via format!, a variable, or with different spacing silently escapes the assertion, so the guard could quietly stop guarding. Not blocking, but worth a comment noting the limitation, or broadening to match any --[a-z0-9-]+ literal in the run_case body.

Comment on lines +911 to +915
// Deliberately no --no-pager: it is registered only on operations that
// declare pagination metadata, so pushing it unconditionally made clap
// reject every invocation ("unexpected argument '--no-pager'") on any spec
// without pagination markers — the whole suite, not one case. It was also
// inert here: the pager only spawns under --page-all, which no case passes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 suggestion

Five lines of post-mortem in every generated wire_test.rs is a lot of noise for consumers who never saw the bug. Consider trimming to one line in the emitted Rust and keeping the full rationale in the changelog/test comment where it already lives.

Suggested change
// Deliberately no --no-pager: it is registered only on operations that
// declare pagination metadata, so pushing it unconditionally made clap
// reject every invocation ("unexpected argument '--no-pager'") on any spec
// without pagination markers — the whole suite, not one case. It was also
// inert here: the pager only spawns under --page-all, which no case passes.
// No --no-pager: the CLI registers it only on paginated operations, and the
// pager only spawns under --page-all, which no case passes.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@cadesark cadesark closed this Aug 28, 2026
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