Repository navigation
Show the server's OAuth error when sign-in is refused - #162
Open
ammartahamohamedy wants to merge 2 commits into
Open
ammartahamohamedy wants to merge 2 commits into
ammartahamohamedy wants to merge 2 commits into
Conversation
This branch has not been deployed
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 #161
Problem
The sign-in endpoints refuse with an OAuth error body (
error,error_description).device::start, anddevice::finishfor codes it has no arm for, passed the reply toHttp::problem, which reads only problem-details members. So a refused scope (--scope knowledge:read, a typo, more than ten scopes) printedHTTP 400: Bad Request, and the server's explanation was lost.Fix
device.rs:OAuthErrorgainserror_description. A refused reply that parses as an OAuth error becomes the existingApiError::Problem, with its detail set to the description (throughterminal_safe), or to theerrorcode when the description is missing or blank, and its code set to theerrorcode. When both are blank, and for a body that isn't an OAuth error, the reply goes throughHttp::problemas before, so the message never says less thanmain.startfor every refused request, and infinish's catch-all arm.Http::problem,ApiError, the four codesfinishhandles (access_deniedkeeps its text), and the exit code.Tests (written first; failed before the change)
a_refused_sign_in_shows_the_servers_oauth_error(new,tests/http.rs)start(invalid_scope) and a refusedfinish(invalid_grant) each print the server's description and keep the OAuth code; an ESC in the description comes out escaped. A body with no description, or a blank one, prints the code instead of "Bad Request"; with a blank code too, it prints "Bad Request" as before (round 1)Mutation checks: reading
start's refusal orfinish's catch-all throughHttp::problemagain, droppingterminal_safe, printing a blank description, or printing nothing when both fields are blank each fails the test.Checks
cargo fmt --check: ✅cargo clippy --locked -- -D warnings: clean on the lib, the bins and the integration tests.--all-targetsstops at the 2 errorsmainalready has on Windows (src/agent/tests.rs).cargo test --locked:tests/http.rspasses (41 tests), and the rest of the suite has only the same 12 Windows failures as onmain(tests/mcp.rs×7,agent_install×2,update,local_patch,hookson a Windows push URL), none of them in this change.cargo deny check: no dependency changes.checkandwindowson both roundsOverlaps: #82 and #118 also edit
device::startanddevice::finish(an origin check, a poll deadline); the conflicts are textual only.Proofline review log
Fork review PR: ammar-taha-dev/proofline-cli#8. Rounds capped at 2.
OAuthError::refusalskips a blankerror_descriptionbut not a blankerror, so{"error": " "}printsHTTP 400:with nothing after it, less thanmain's "Bad Request"Http::problem. Two test cases added first (blank code; empty code with a blank description), failing before the changeerrorwith a usable description is kept asSome(" ")inApiError::Problem.codescan.rsreadsApiError::code()), and a blankerrorbreaks the OAuth error format. The printed message is already correctThe prompts below are the ones that drove this implementation; the investigation, reproduction and fix scope were done before them and aren't included.