Repository navigation
fix(sign-in): judge the probe's 401 once, and renew an ended token a 401 met - #41
Merged
Merged
Conversation
The connection kept the probe's 401 as a flag (`refused_with_token`) and worked out "token not received" from it and the token held when asked, which a token kept or dropped since could change. It now keeps the probe's `Unauthorized` (`Connection::refusal`), judged as every request's is, and the Open dialog's line reads it in one arm. `Challenge::refuses`, left with one caller, folds into `Unauthorized::judge`.
A request refused for the ended token kept while its source could not answer (the server back before the source, after a wake) asked the source as after a refusal of the account, so its answer was a new credential and every graph read everything again. A 401 to a token past its end now asks for its renewal (once, as any refusal, and nothing beside an ask under way). A connection unauthorized with no probe's 401 standing takes the same holder's next token as a renewal, and that renewal connects again, making the connection ready.
ragnorc
force-pushed
the
refactor/probe-judgement-20261030
branch
from
October 31, 2026 19:30
674d3c4 to
7916fc6
Compare
ragnorc
marked this pull request as ready for review
October 31, 2026 19:30
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.
Follows #40, now merged; this is rebased onto main.
Keep the probe's 401 as its judgement
The connection kept the probe's 401 as a flag (
refused_with_token) and worked out "token not received" from that flag plus whether a token was held at the time it was asked. A token kept or dropped since then could change the answer; #37's kept ended token already needed a patch for this. The connection now keeps the probe'sUnauthorizedjudgement (Connection::refusal), judged the same way as every request's, and the Open dialog's line reads it in one arm.Challenge::refuseswas left with one caller, so it folds intoUnauthorized::judge.A refusal of an ended token asks for its renewal
This was the last item #40 left. Suppose the token ends while its source can't answer, and the server comes back before the source does (after a wake, say). A request refused for that ended token asked the source as if the server had refused the account. Its answer was then a new credential, and every graph read everything again.
Now:
Testing
cargo fmt --all --check,cargo clippy --workspace --all-targets -- -D warnings,cargo test --workspace(1,159 passed) and the repo checks pass locally.connection::tests::a_refusal_of_an_ended_token_asks_for_its_renewal.Note
Medium Risk
Changes OAuth connection state, 401 interpretation, and token renewal vs refusal retry paths; mistakes could mis-handle credentials or over-trigger full re-reads, though behavior is pinned by new and updated tests.
Overview
Replaces the connection’s
refused_with_tokenboolean withrefusal: Option<Unauthorized>, storing the connect/graph-list probe’s 401 outcome the same way as other requests.Challenge::refusesis removed;Unauthorized::judgeis the single place that maps a Bearer challenge plus “was a token sent?” to TokenRefused, TokenNotReceived, or TokenNeeded. Status copy,token_not_received(), and the Open Graph dialog now read that enum instead of re-deriving “not received” from flags and whether a token is still held.Behavior change: when a graph request is refused for a source-held token that is already past its end (e.g. server back before the CLI after wake),
request_refusedasks the source for a renewal (Ask::Renewal) rather than an account-style refusal retry. Renewals while unauthorized (including when there is no probe 401, only “source gave nothing”) can connect again so the connection returns to ready without treating the answer as a new credential that re-reads every graph.Reviewed by Cursor Bugbot for commit 7916fc6. Bugbot is set up for automated code reviews on this repo. Configure here.