feat(core): let a caller read an endpoint's rejection body - #1804
Conversation
sileht
had a problem deploying
to
func-tests-live
September 4, 2026 23:20 — with
GitHub Actions
Failure
Member
Author
|
This pull request is part of a Mergify stack:
|
Contributor
Merge Protections🔴 3 of 7 protections blocking · waiting on 👀 reviews and ⛓️ dependency
🔴 ⛓️ Depends-On RequirementsWaiting for
This rule is failing.Requirement based on the presence of
🔴 👀 Review RequirementsWaiting for
This rule is failing.
🔴 🔎 ReviewsWaiting for
This rule is failing.
Show 4 satisfied protections🟢 🤖 Continuous Integration
🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 📕 PR description
🟢 🚦 Auto-queueWhen all merge protections are satisfied, this pull request will be queued automatically. |
This was referenced Sep 4, 2026
Every verb on the HTTP client renders a non-2xx response into a
`CliError` and drops the body. That is right for an API where a
rejection is a failure, and wrong for one where it is an answer: the
OAuth device grant replies `400 {"error": "authorization_pending"}` to
every poll until its owner approves in a browser, so a client that could
only see "the request failed" could never complete the flow. `GET
/v1/user` has the same shape from the other side -- a refused credential
(403) and a deployment too old to serve the route (404) are different
sentences to the user, and both differ from a network failure.
`post_form` and `get_outcome` return an `ApiOutcome`: the decoded body
on success, and the status plus the decoded error body on a terminal
rejection. Retries are untouched -- 5xx and rate limits are retried
before anything is handed back -- and a rejection whose body does not
deserialize as the protocol's error type stays a plain `CliError`, so a
proxy's HTML 502 page is as diagnosable as it is on every other verb.
Inside the driver, `tolerate_not_found: bool` becomes a three-valued
`OnTerminalError`, because the third case is not a boolean and a third
bool would have tripped `clippy::fn_params_excessive_bools`. The one
ordering change it forces: the retry decision is now taken before the
error body is read, since rendering the message consumes the very bytes
the caller asked for.
`post_form_no_response` covers the revocation endpoint, which answers
200 with an empty body. Form encoding needs reqwest's `form` feature;
the device grant is the only thing in the CLI that sends one.
Fixes MRGFY-8703
Change-Id: I9339bdfbb74edbf3399a529e602007d96bfda074
sileht
force-pushed
the
devs/sileht/mrgfy-8703-cli-auth-commands/let-caller-read-endpoint-s-rejection-body--9339bdfb
branch
from
September 4, 2026 23:40
3c5d1dd to
9ca0419
Compare
sileht
force-pushed
the
devs/sileht/mrgfy-8703-cli-auth-commands/store-mergify-credential-os-keychain--bd91cd6d
branch
from
September 4, 2026 23:40
7273861 to
e0609e3
Compare
sileht
had a problem deploying
to
func-tests-live
September 4, 2026 23:40 — with
GitHub Actions
Error
sileht
had a problem deploying
to
func-tests-live
September 4, 2026 23:40 — with
GitHub Actions
Failure
Member
Author
Revision history
|
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.
Every verb on the HTTP client renders a non-2xx response into a
CliErrorand drops the body. That is right for an API where arejection is a failure, and wrong for one where it is an answer: the
OAuth device grant replies
400 {"error": "authorization_pending"}toevery poll until its owner approves in a browser, so a client that could
only see "the request failed" could never complete the flow.
GET /v1/userhas the same shape from the other side -- a refused credential(403) and a deployment too old to serve the route (404) are different
sentences to the user, and both differ from a network failure.
post_formandget_outcomereturn anApiOutcome: the decoded bodyon success, and the status plus the decoded error body on a terminal
rejection. Retries are untouched -- 5xx and rate limits are retried
before anything is handed back -- and a rejection whose body does not
deserialize as the protocol's error type stays a plain
CliError, so aproxy's HTML 502 page is as diagnosable as it is on every other verb.
Inside the driver,
tolerate_not_found: boolbecomes a three-valuedOnTerminalError, because the third case is not a boolean and a thirdbool would have tripped
clippy::fn_params_excessive_bools. The oneordering change it forces: the retry decision is now taken before the
error body is read, since rendering the message consumes the very bytes
the caller asked for.
post_form_no_responsecovers the revocation endpoint, which answers200 with an empty body. Form encoding needs reqwest's
formfeature;the device grant is the only thing in the CLI that sends one.
Fixes MRGFY-8703
Depends-On: #1803