Skip to content

fix(auth): name the provider's reason on the failed sign-in tab - #36706

Open
bolichen97 wants to merge 1 commit into
mainfrom
fix/36161-callback-provider-reason
Open

bolichen97 wants to merge 1 commit into
mainfrom
fix/36161-callback-provider-reason

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

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 error code, but the callback listener answered every failure with the same line. wait_for_callback in auth/login/portal.py now 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:

error in the redirect Tab says
access_denied Login failed: the sign-in was cancelled or not approved. You can close this window and retry from the dashboard.
server_error Login failed: the sign-in service ran into a problem. You can close ...
temporarily_unavailable Login failed: the sign-in service is temporarily unavailable. You can close ...
invalid_request, unauthorized_client, unsupported_response_type, invalid_scope Login failed: the sign-in service did not accept the request. You can close ...
anything else Login failed. You can close this window and retry from the dashboard. (as before)

The words are fixed on purpose. The provider's error_description is 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_denied covers both a user who cancelled and a sign-in that was not allowed, so its line names both. The kas-auth spec's loopback contract says the same.

Backwards compatibility

Compatible: the poll answer, its code and its error text 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_error is parametrized over four standard codes and one unknown code, each sent with an error_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)

c2fa8b08d555 is this PR's commit applied with git am onto the same base on the test host (identical patch-id).

Determinism: 20 of 20 runs at -n0 of 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:

Callback Before After
error=access_denied, description "The user cancelled the sign-in." Login failed. You can close this window and retry from the dashboard. Login failed: the sign-in was cancelled or not approved. You can close this window and retry from the dashboard.
error=temporarily_unavailable Login failed. You can close ... Login failed: the sign-in service is temporarily unavailable. You can close ...
error=server_error, description <b>bold</b> (not run) Login failed: the sign-in service ran into a problem. You can close ... ("bold" absent from the page)
error=something_else (not run) Login failed. You can close this window and retry from the dashboard.
login_option=google&code=... (good sign-in) (not run) Login complete. You can close this window. (poll ends 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:

before, access_denied

After, error=access_denied:

after, access_denied

After, the other codes

after, temporarily_unavailable

after, server_error with markup in the description

after, an unknown code

Related Issues

Closes #36161

Touches the same callback answer in auth/login/portal.py as 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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

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
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 1 — duplicate of src/kiro_crew/connections/crew_oauth.py:114: the RFC 6749 code list now exists twice ("access_denied": "callback_access_denied" there, _PORTAL_ERROR_REASONS here). The outputs differ (refusal codes there, page words here), so this stays a note. Subtraction: none smaller without a shared module that only two places would use.

What this change ships

Inventory (3 items) — 3 justified

Intent: someone whose browser sign-in fails or is cancelled can see why on the tab it lands on. This is a FIX.

  1. The failed sign-in tab names a fixed reason for each of the seven standard OAuth error codes — justified
  2. An unknown error code still shows the old "Login failed." line — justified
  3. The kas-auth spec now states the loopback failed-page wording rule — justified

[FIRST-PRINCIPLES-REVIEWED] 51e6d00

Description read

[DESCRIPTION-READ] 103db6981b359f6b365e4e4c9813bf943a782813a994794b8baa4e9bdebc7aa7

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 51e6d00

Verdict parsed from the review's SHA-scoped output markers for commit 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c false-positive: <reason, 20 to 500 characters>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 51e6d00

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 51e6d008df4a0b02a008ce5cc035e0f2efb6f95c false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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. reason is set only on the first error, when the sign-in fails, so later hits show the same reason. A state mismatch, a missing code or a timeout keeps the old wording. The poll answer, the success page and the 404 handler are unchanged. The parametrized test would fail on main, and the spec line matches the code.

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 51e6d008df · 48 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 15:50
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The red on this head is main's, not this change's. Backend Tests (3.12, 7) lost its runner ("The self-hosted runner lost communication with the server", no log), and Coverage Gate failed closed behind it. The same job lost its runner the same way on main: https://github.com/kirodotdev/KiroCrew/actions/runs/43458639790/job/132007560951 (head 6a357581ca). It is the shard 7 memory ceiling tracked in #36261, which #36653 fixes (#36648 also takes memory off that shard).

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 51e6d008df are unchanged.

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bolichen97

Copy link
Copy Markdown
Contributor Author

[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 test/test_conductor_agent.py::TestConductorInstaller::test_back_to_back_rounds_keep_a_spend_bound (#37243): its "at most 6" check matches inside "at most 600" in the goal-conductor skill, so the full backend suite fails it on any branch rebased onto today's main. Pushing now would spend a full CI run on a known red, so this PR waits for that fix, #37254, then re-syncs onto main and runs CI again.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The browser callback page does not name the reason the provider gave

3 participants