Repository navigation
fix(kiro): stop leftover CLI profile ARN from collapsing a second account - #4482
Conversation
…p ci] JSON null appliedFingerprint/appliedAt is treated as unset, matching appliedMarkers(). An still-invalid desktopProfile is salvaged by dropping that field only, so one bad Claude Desktop marker cannot replace the operator config with defaults. Closes #4430
…ount Same-session whoami is the live Kiro identity. SQLite state can still hold the previous profile after a CLI switch, and using that ARN as accountId upserted the new login onto the first slot. The Builder ID service profile is also excluded from account identity. Closes #4435
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
리뷰 · 우선순위 77 / 80설명 수정은 우선순위 77은 멀티 계정 데이터가 조용히 사라지는 운영 사고를 막고, 변경이 kiro oauth+테스트로 매우 좁기 때문이다. tip
심볼 #4435 / #993 - whoami 우선이 #993을 깨지 않는지 테스트가 핵심. diff상 세션 스위치 discard는 유지. 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f496a321f9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const resolvedProfileArn = accountScopedProfileArn(identity.profileArn) | ||
| ?? accountScopedProfileArn(imported.profileArn); |
There was a problem hiding this comment.
Avoid the stale ARN fallback for profileless whoami
When a fresh login switches from an account-scoped profile to Builder ID, whoami can succeed with an email plus the fixed service ARN (or no ARN). accountScopedProfileArn(identity.profileArn) is then undefined, so this fallback reuses the previous account's SQLite profile; because saveCredential matches accountId before email, the new credentials overwrite the first slot—the collapse this patch is meant to stop. Treat a successfully revalidated whoami identity as authoritative even when it has no account-scoped ARN.
Useful? React with 👍 / 👎.
| const base = metadataFromImported(imported) ?? {}; | ||
| if (resolvedProfileArn && !base.profileArn) base.profileArn = resolvedProfileArn; | ||
| if (resolvedProfileArn) base.profileArn = resolvedProfileArn; |
There was a problem hiding this comment.
Recompute the region when replacing the imported profile
When whoami supplies profile ARN B over stale SQLite ARN A, metadataFromImported(imported) has already retained apiRegion inferred from A, and this block replaces only profileArn. Since resolveKiroApiRegion prioritizes apiRegion over the new profile's region, a cross-region second account is subsequently sent to the old account's endpoint; filtering the Builder ID service ARN likewise leaves its inferred us-east-1 behind. Clear or recompute profile-derived apiRegion whenever the imported profile is discarded or replaced.
Useful? React with 👍 / 👎.
| /** Account identity must never use the request-scoped Builder ID service profile. */ | ||
| function accountScopedProfileArn(value: unknown): string | undefined { | ||
| const parsed = parseKiroProfileArn(value); | ||
| return parsed && parsed !== KIRO_BUILDER_ID_SERVICE_PROFILE_ARN ? parsed : undefined; |
There was a problem hiding this comment.
Update all mapped OAuth structure documents
This changes src/oauth/, but only structure/runtime.md is updated; structure/INDEX.md maps that source area to structure/runtime.md, structure/transports/inventory.md, and structure/providers/xai-grok.md. The scoped repository rule requires every mapped document to be updated in the same change, so synchronize the other two documents (or correct the ownership map if they no longer describe OAuth).
AGENTS.md reference: src/AGENTS.md:L11-L11
Useful? React with 👍 / 👎.
Lane I2 of the contributor carry train: two reported defects with no source branch. lidge-jun#4430 (samwang0041-star) — 2.52.0 treated claudeCode.desktopProfile.appliedFingerprint=null as fatal and replaced the whole configuration with defaults. Accepting null is the immediate fix; the landing also narrows the reset path so one invalid field cannot destroy a user's providers. lidge-jun#4435 (ren-min-wan-sui) — a second Kiro account disappeared shortly after a successful login, because a leftover CLI profile ARN collapsed it onto the first. Cross-platform CI run 34745142783 concluded success on 3238428, the exact head merged here, which already contains a merge of origin/dev. lidge-jun#4479 carries no ci check of its own; its head commit carries [skip ci] by design and this cumulative tip run covers its content, under the owner-authorized tip-only CI economy for this batch. No Co-authored-by trailer: both links are ordinary implementations with no contributor branch behind them, and the reporters are credited in the pull request descriptions.
|
This issue still occurs after the fix in #4482. Environment:
After logging in with a second Kiro account, I still cannot keep two separate accounts. The account appears to revert to the previous one. Local investigation found a possible remaining cause:
An isolated reproduction using dummy credentials and the installed code confirmed that importing new tokens with the old cached ARN updates the existing account slot instead of creating a second account. The account count remains 1. This reproduces an account-identity collision, although I have not confirmed whether it fully explains the behavior of my live login. Could you please investigate this fallback path and reopen #4435 if appropriate? |
Summary
~/.opencodex/auth.json.saveCredentialalready keeps two slots whenaccountIds differ — including two accounts that share an email. The collapse is an identity upsert: afterkiro-cli login, SQLitestatecan still hold the previousapi.codewhisperer.profileARN, import treated that leftover ARN asaccountId, and the new tokens overwrote the first slot.whoamiis now the live identity when the CLI token still matches the import. The Builder ID service profile ARN is never persisted asaccountId/kiro.profileArn. A session switch still discards whoami ([Bug]: Kiro provider profileArn required 400 for Builder ID accounts on gated models #993).Verification
bun test tests/providers/kiro/kiro-review-regressions.test.ts tests/providers/kiro/kiro-oauth.test.ts tests/oauth/oauth-store-multi.test.ts tests/oauth/oauth-reauth-bind.test.tsbun run typecheckbun run structure:checkbun run privacy:scanci.ymlon this exact head is the lane gate.Stacked on #4479 (
codex/260913-carry-4430).Checklist