Skip to content

fix(kiro): accept the authorized status from the social device poll - #7053

Draft
Veritas-7 wants to merge 1 commit into
lidge-jun:devfrom
Veritas-7:fix/kiro-device-authorized-status
Draft

Veritas-7 wants to merge 1 commit into
lidge-jun:devfrom
Veritas-7:fix/kiro-device-authorized-status

Conversation

@Veritas-7

@Veritas-7 Veritas-7 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Native Kiro social device login (ocx account login kiro --method google or --method github) always ends in failed after the user approves the login in the browser, and no account is stored. The poll branch in src/oauth/kiro-device-login.ts treats any non-approved status as terminal failure, but the social poll endpoint reports a completed grant as status: "authorized".

Observed replies from POST https://prod.us-east-1.auth.desktop.kiro.dev/oauth/device/poll (2026-10-13; keys and non-secret values only, token values and the account number withheld):

  • While waiting: HTTP 200, status: "authorization_pending"; accessToken, refreshToken and profileArn are present as null.
  • After approval: HTTP 200, keys accessToken, identityProvider ("Google"), profileArn (arn:aws:codewhisperer:us-east-1:<account>:profile/<id>), refreshToken, status: "authorized". No expiresIn and no error key.

The fix accepts "authorized" as the social success status and keeps "approved" as an alias, so existing behavior and tests are unchanged. Every other check on the success path still applies: HTTP 200, no error key or x-amzn-errortype, non-empty access and refresh tokens, and a profileArn matching the existing pattern. Unknown statuses still fail closed. The Builder ID branch is untouched.

Changed files:

  • src/oauth/kiro-device-login.ts: accept "authorized" in the social poll success check (one condition).
  • tests/providers/kiro/kiro-device-social.test.ts: a regression that replays the observed sequence (authorization_pending with null tokens, then authorized with identityProvider) and asserts the flow stays pending and stores nothing, then reaches done and persists the refresh token and profile ARN without leaking tokens into the public view.

Verification

Base: dev at e2886a64a (rebased; the focused results below were re-run on this base: the four device-login files give 21 pass, 0 fail, and bun run typecheck passes). Earlier figures were measured on 60752ec3c. Tests were run with Bun 1.4.2 (the runtime the package ships); CONTRIBUTING pins 1.4.3 for the suite runner, so CI is the authoritative run.

  • bun test ./tests/providers/kiro/kiro-device-social.test.ts: 4 pass, 0 fail.
  • Mutation check: with only the src/ change reverted, the same file gives 3 pass, 1 fail. The new case fails with Expected: "done" / Received: "failed", which is the reported symptom.
  • bun test ./tests/providers/kiro/kiro-device-social.test.ts ./tests/providers/kiro/kiro-device-builder.test.ts ./tests/server/server-kiro-device-login.test.ts ./tests/cli/cli-account-kiro-device.test.ts ./tests/ci-workflows/file-size-ratchet.test.ts: 30 pass, 0 fail.
  • bun run typecheck: passed.
  • bun run structure:check: passed.
  • bun run privacy:scan: passed.
  • git diff --check: clean.

I did not run the full local suite (bun run test). The change is a single condition in one module, and the focused files above cover the social, Builder ID, server and CLI device-login paths. Required CI on the PR head still has to pass.

Checklist

  • Scope stays focused and avoids unrelated cleanup: one condition in the social poll branch plus one regression test. Builder ID handling, token validation and persistence are unchanged.
  • Docs or release notes were updated when needed: none needed. No documented behavior or structure/ contract names the poll status value.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults: the success path still requires HTTP 200, no error, non-empty tokens and a valid profile ARN, and unknown statuses still fail closed. The test asserts that tokens never reach the public flow view. This touches an authentication surface, so it needs maintainer sponsorship (maintainer-sponsored) per CONTRIBUTING.

🤖 Generated with Claude Code

Review readiness checklist

This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:

  • Required local validation passed; commands, results, and any full-suite exception are documented.

  • I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

Summary by CodeRabbit

  • Bug Fixes
    • Social device sign-in now recognizes “authorized” as a successful completion status, while continuing to accept “approved.”

@github-actions github-actions Bot added the intake: hygiene-blocked Deterministic PR hygiene checks failed label Oct 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Deterministic hygiene checks failed.

  • unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/oauth/kiro-device-login.ts.

@github-actions github-actions Bot added the bug Something isn't working label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • hygiene: unsponsored_surface.

What to do

  • Fix unsponsored_surface — This changes an authentication, workflow, release-automation, or dependency surface. MAINTAINERS.md requires security review for these; ask a maintainer to apply maintainer-sponsored once they have reviewed it. Paths: src/oauth/kiro-device-login.ts.

Review readiness checklist

  • ✅ Required local validation passed; commands, results, and any full-suite exception are documented.
  • ✅ I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
  • ✅ I resolved all correct Codex and CodeRabbit findings.
  • ✅ My PR is ready for review.

✅ 4/4 boxes ticked.

This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions
github-actions Bot marked this pull request as draft October 13, 2026 15:10
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: lidge-jun/opencodex/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: f0f66490-57b2-4654-9304-06599a590548
📥 Commits

Reviewing files that changed from the base of the PR and between a29cb3d and 1dc9a66.

📒 Files selected for processing (2)
  • src/oauth/kiro-device-login.ts
  • tests/providers/kiro/kiro-device-social.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

Social device polling now accepts authorized as a completed-grant status while retaining approved as an alias. A test covers a pending poll followed by an authorized response.

Changes: Kiro social device authorization

Layer / File(s) Summary
Accept authorized social grants
src/oauth/kiro-device-login.ts, tests/providers/kiro/kiro-device-social.test.ts
The status check accepts authorized alongside approved. The test verifies that a pending poll creates no account, then checks grant completion, stored refresh token and profile ARN, and omission of credential secrets from the returned status.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 1dc9a

The authorized social login now completes through the existing credential checks and persistence flow. No merge-blocking issue is identified.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: accepting the "authorized" status from the Kiro social device poll.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The Kiro social device poll reports a completed grant as status
"authorized", but the poll branch only accepted "approved", so every
Google/GitHub device login ended as failed after browser approval and no
account was stored. Accept "authorized" and keep "approved" as an alias;
all other success checks are unchanged.

Assisted-by: Claude Opus 5.5 (Claude Code)
@lidge-jun

Copy link
Copy Markdown
Owner

Carried onto an upstream branch in #7062 (with a Co-authored-by trailer) so the repository CI can run. It is held there for the security review that MAINTAINERS.md requires for authentication changes. Leaving this PR open until that review concludes.

lidge-jun added a commit that referenced this pull request Oct 13, 2026
…top Bad credentials (#7053, #7054) (#7062)

* fix(kiro): accept authorized social device grants

Carries #7053. Preserve token, profile, principal, and HTTP validation.

Co-authored-by: Veritas-7 <234569343+Veritas-7@users.noreply.github.com>

* fix(kiro): quarantine exact desktop bad-credentials refusals

Carries #7054. Keep AWS SSO and other status/message pairs retryable.

Co-authored-by: Veritas-7 <234569343+Veritas-7@users.noreply.github.com>

* fix(chatgpt): preserve launcher when app inspection fails

Carries #7055. Report unknown inspection state and refuse an unconfirmed restart.

Co-authored-by: lcxhh <lcxhh521@gmail.com>

* fix(proxy): bound SOCKS5 TLS handshake lifetime

Carries #7056. Clear deadline and listeners on every TLS handshake exit while keeping certificate verification.

Co-authored-by: lcxhh <lcxhh521@gmail.com>

* docs: triage exceeded-retry-limit 429 errors

Carries #6925. Align refresh release conditions and the resolved credit rediscovery reference with current dev.

Co-authored-by: Howard-Jerry <197214646+Howard-Jerry@users.noreply.github.com>

---------

Co-authored-by: JUN <243035832+lidge-jun@users.noreply.github.com>
Co-authored-by: Veritas-7 <234569343+Veritas-7@users.noreply.github.com>
Co-authored-by: lcxhh <lcxhh521@gmail.com>
Co-authored-by: Howard-Jerry <197214646+Howard-Jerry@users.noreply.github.com>
Co-authored-by: jun <jun@juns-Mac-Studio.local>

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

bug Something isn't working intake: hygiene-blocked Deterministic PR hygiene checks failed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants