Repository navigation
fix(auth): name the provider's reason on the failed sign-in tab - #36706
bolichen97 wants to merge 1 commit into
Conversation
When the sign-in page sent the browser back with an error, the tab said only "Login failed. You can close this window and retry from the dashboard." whatever the reason, so a cancelled sign-in and a sign-in service outage looked the same. The tab now names the reason for each RFC 6749 error code in fixed words, for example "Login failed: the sign-in was cancelled or not approved." An unknown code keeps the old line. Nothing the request carries, error_description included, is put on the page: that text is meant for developers and the request is not trusted. Closes #36161
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the reason comes from a fixed table keyed on the RFC 6749 code, nothing from the request reaches the page, and the poll contract is unchanged. [DESIGN-REVIEWED] 51e6d00 Description read[DESCRIPTION-READ] d84f3c98499bae49233958191a67e9bdade6fba1ff10889892368c82231a66cf That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: one fixed-wording table fills the failed tab's reason, tied to #36161 and pinned by a test that fails on base. Notes
What this change shipsInventory (3 items) — 3 justifiedIntent: someone whose browser sign-in fails or is cancelled can see why on the tab it lands on. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] 51e6d00 Description read[DESCRIPTION-READ] 103db6981b359f6b365e4e4c9813bf943a782813a994794b8baa4e9bdebc7aa7 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: ApproveWhy: the decider estimates a 6% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. The failed loopback sign-in page now names a fixed reason for each of the seven RFC 6749 error codes, looked up in a closed table. Nothing from the untrusted callback (error_description, markup) reaches the page, and the test covers that. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
|
[operator: bolichen97] The red on this head is main's, not this change's. This PR waits for that fix instead of rerunning into the same ceiling: once #36653 merges, the branch re-syncs onto it and CI runs again. The diff (3 files, +43/-5) and the reviews on |
buluoray
left a comment
There was a problem hiding this comment.
Approve on 51e6d00. The failed sign-in tab now names a reason for each of the seven standard OAuth error codes. The reason comes from a fixed table in the code, so nothing that the callback request carries, including the provider's description, reaches the page. An unknown code keeps the old wording. A sign-in that worked still shows "Login complete", and the poll answer is unchanged. The updated test fails when the table lookup is removed, and it fails when the provider's text is put on the page. No route was added and no check was loosened. Approve. Decisive lines: src/kiro_crew/auth/login/portal.py:50-58, src/kiro_crew/auth/login/portal.py:201, src/kiro_crew/auth/login/portal.py:217-222, test/test_kas_login_loopback.py:259-288
|
[operator: bolichen97] Holding the re-sync for one more fix. The shard 7 memory fixes this branch was waiting for are on main now (#36648, #36731), and a rebase onto main is clean with the diff unchanged (3 files, +43/-5). main itself is red right now on |
Problem / Motivation
Goal: When the sign-in page sends the browser back with an error, the browser tab says the reason the provider gave instead of a bare "Login failed".
After a browser sign-in that the provider refuses, or that the user cancels, the tab the browser lands on said only "Login failed. You can close this window and retry from the dashboard.", whatever the reason the provider sent back.
Why it matters
Anyone who cancels the sign-in, or whose sign-in service has a problem, is left with a page that does not say what went wrong, so they cannot tell a cancel from an outage or decide whether trying again will help.
Not a goal
What changed (motivation → approach → change)
The provider's redirect names its reason in the standard OAuth
errorcode, but the callback listener answered every failure with the same line.wait_for_callbackinauth/login/portal.pynow looks the code up in a fixed table of the seven RFC 6749 §4.1.2.1 codes,_PORTAL_ERROR_REASONS, and the failed page names that reason:errorin the redirectaccess_deniedserver_errortemporarily_unavailableinvalid_request,unauthorized_client,unsupported_response_type,invalid_scopeThe words are fixed on purpose. The provider's
error_descriptionis meant for developers, and the callback request is not trusted, so nothing it carries is put on the page; the sibling connection sign-in follows the same rule.access_deniedcovers both a user who cancelled and a sign-in that was not allowed, so its line names both. Thekas-authspec's loopback contract says the same.Backwards compatibility
Compatible: the poll answer, its code and its
errortext are unchanged; only the failed page's line gains a reason.Removes nothing: no path, key or answer is taken away; the failed page only gains a reason for the standard codes.
Tests
test_loopback_portal_error_is_erroris parametrized over four standard codes and one unknown code, each sent with anerror_description: the tab names the code's fixed reason (the unknown code keeps the old line), the provider's text never appears on the page, and the poll answer is unchanged.Proof: PROVEN test/test_kas_login_loopback.py::test_loopback_portal_error_is_error[access_denied-Login failed: the sign-in was cancelled or not approved. You can], test/test_kas_login_loopback.py::test_loopback_portal_error_is_error[server_error-Login failed: the sign-in service ran into a problem. You can], test/test_kas_login_loopback.py::test_loopback_portal_error_is_error[temporarily_unavailable-Login failed: the sign-in service is temporarily unavailable.], test/test_kas_login_loopback.py::test_loopback_portal_error_is_error[invalid_scope-Login failed: the sign-in service did not accept the request. You] (head c2fa8b08d555)
c2fa8b08d555is this PR's commit applied withgit amonto the same base on the test host (identical patch-id).Determinism: 20 of 20 runs at
-n0of the five parametrized ids passed, and one shuffled-order run of the whole file (27 ids, seed 25268) passed.Manual verification
Run on Linux (Ubuntu 24.04) against an isolated gateway (fresh
KIROCREW_HOME,KIRO_AUTH_TRANSPORT=loopback, a local token stub), with Chromium opening the callback address the sign-in page redirects to. Before and after this commit:error=access_denied, description "The user cancelled the sign-in."error=temporarily_unavailableerror=server_error, description<b>bold</b>error=something_elselogin_option=google&code=...(good sign-in)authorized)Every failed case ended the poll with
{"status": "error", "code": "loopback_failed", "error": "portal returned error: <code>"}, the same as before. The static gates,mypy,scripts/local-gate.py, the flake-pattern ratchet and the repository's semgrep rules on the diff all passed on the same host.Screenshots / video
The page the browser tab lands on after a failed sign-in, captured from this commit on the test host.
Before,
error=access_denied:After,
error=access_denied:After, the other codes
Related Issues
Closes #36161
Touches the same callback answer in
auth/login/portal.pyas the fix for #36159 (the tab's title and go-back line); whichever merges second re-syncs onto the other.Sibling sweep
Swept: git grep -nE 'query.get("error"' -- src/kiro_crew
Sibling: src/kiro_crew/connections/crew_oauth.py:742 -- not affected -- the connection sign-in already maps the provider's error onto a closed set of coded refusals the Connections panel words itself
Pattern harvest
Not generalizable: the other OAuth callback already maps the error code onto fixed wording, and this was the one page that answered every code with the same line.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)