fix(client): don't reject unexpected success when no 2xx is declared - #90
Merged
lightsofapollo merged 1 commit intoOct 2, 2026
Merged
Conversation
An operation that declares no 2xx response, such as one with only a `default` response, selects every successful status: its success guard is `status.is_success()` itself. The branch after it, which rejects the successful statuses the return type didn't select, tested the same condition, so it couldn't be reached, and clippy's deny-by-default `ifs_same_cond` rejected the generated client. The branch is now emitted only when there are selected statuses to reject, in the buffered, binary and streaming paths alike. The corpus moves for the 15 specs with such operations, by exactly those 342 branches. Refs gpu-cli#89: the duplicated branch, not the variant names.
|
@iamralch is attempting to deploy a commit to the lbl-rd Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Oct 2, 2026
iamralch
added a commit
to cf-contrib/cloudflare-rs
that referenced
this pull request
Oct 3, 2026
openapi-to-rust's main has gpu-cli/openapi-to-rust#90, #91 and #92, which no release has yet: - Builders compile for every operation, so they're on: an operation with more than three optional parameters also has a `*_builder()`, and `zones_get_builder().per_page(50.0).send()` replaces ten positional Options. - Requiredness-only unions that say `type: object` are constraints, so the overlay no longer removes them from Email Sending and Magic WAN. - An operation with only a `default` response has no duplicated branch, so clippy::ifs_same_cond is no longer allowed. The generator is a git dependency at a pinned commit until a release.
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.
Fixes the first half of #89: the duplicated
status.is_success()branch. The variant naming it also mentions (AmberStrict_2) is left for a separate PR.What was wrong
An operation that declares no 2xx response, such as one with only a
defaultresponse, selects every successful status, so its success guard isstatus.is_success()itself. The branch after it, which rejects successful statuses the return type didn't select, tested the same condition:It couldn't be reached, and clippy's deny-by-default
ifs_same_condrejected the generated client.The change
generate_error_handlingemits the branch only when there are selected statuses to reject (!success.statuses.is_empty()). That covers the buffered path, which is the one clippy caught, and the binary and streaming paths, where the same check was nested inside theelseand just as unreachable.Tests
tests/default_only_response_test.rs: adefault-only operation testsstatus.is_success()once and has no unexpected-success branch, and an operation with a declared204still rejects other successes. It fails before this change.cargo test --all-features: 719 passed, none failed.tests/corpus-manifest.txtis regenerated.scripts/gen-diff.sh upstream/mainshows 15 specs moved, all inclient.rs, by 342 removed branches. Forcloudflare(43),github(8) andgoogle-youtube(83), removing exactly those branches from the base output gives the new output byte for byte. The +141 lines in the Cloudflare diff are git aligning similar functions differently.cargo clippy --all-features -- -D warningsreports onenonminimal_boolinsrc/schema_roundtrip.rswith clippy 0.1.93. It's onmainas well, so it isn't from this change.