Skip to content

fix(kiro): validate whoami output before reporting authentication - #37890

Closed
primevishnu wants to merge 1 commit into
pingdotgg:mainfrom
primevishnu:fix/kiro-whoami-auth-validation
Closed

primevishnu wants to merge 1 commit into
pingdotgg:mainfrom
primevishnu:fix/kiro-whoami-auth-validation

Conversation

@primevishnu

Copy link
Copy Markdown
Contributor

Problem and change

Kiro's sign-in check could report authenticated when kiro-cli whoami --format json exited 0 with empty, malformed, or account-less output. Its signed-out detection also depended on the literal substring "account":null, so valid JSON with whitespace was treated as unknown.

Decode a signed-out object or a meaningful account object before assigning authentication state. Accept whole JSON output, including formatted signed-out JSON, while preserving the first-line fallback for the Identity Center Profile: suffix. Unparseable or empty account output remains unknown, and a positive account result still requires a successful exit. The existing warning tells users to check kiro-cli whoami when sign-in cannot be confirmed.

This matters beyond the label: model/agent discovery is gated on confirmed authentication because a signed-out Kiro can start browser login during discovery. Invalid output must not supply positive evidence for that gate.

Proof and verification

Extended the existing parser test rather than adding a second test layer. Before the fix, the regression fails for valid spaced signed-out JSON: expected unauthenticated, received unknown. It also now checks empty output, invalid JSON, an empty object, a missing account type and an empty account type. Existing API-key, Builder ID, Identity Center suffix and failure cases remain covered.

packages/provider-kiro:
vp test run --config ../../vite.config.ts src/server/driver.test.ts --maxWorkers 1
Test Files  1 passed
Tests       4 passed

apps/server:
vp test run src/provider/KiroProvider.test.ts --maxWorkers 1
Test Files  1 passed
Tests       12 passed

Owning-package typecheck, changed-file lint, formatting and git diff --check pass.

A separate lightweight runtime transcript executes the exact parser/schema fragments from base 9d28fc921be19a7314376f6438242dcb838eb221 and the fix with Effect 4.1.3:

{"account":null}, exit 1:       unauthenticated -> unauthenticated
{"account": null}, exit 1:      unknown -> unauthenticated
formatted signed-out JSON:     unknown -> unauthenticated
empty output, exit 0:          authenticated -> unknown
not-json, exit 0:              authenticated -> unknown
{}, exit 0:                    authenticated -> unknown
valid BuilderId account:       authenticated -> authenticated, email retained

Environment: Windows 11 x64, Node 26.13.1, Effect 4.1.3. These are controlled parser/service fixtures; no live Kiro login or paid agent turn was used. The tests do not claim that current official Kiro normally emits corrupt output. This patch makes the existing parser conservative at those boundaries.

Full workspace checks are limited by this low-memory local machine and incomplete desktop/mobile dependency setup. Focused checks above pass; CI provides the broader validation. The earlier root check:changed attempt on the sibling Cursor change failed on that setup, not on this parser's focused checks.

AI-assisted implementation and verification: GPT-6.1 Sol through Codex in T3 Code.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 17, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at f71d7a8

Macroscope's review found this PR approvable — Kiro authentication reporting now requires validated whoami output before marking the provider authenticated. The change is limited to status interpretation and existing probe gating, with no credential or permission changes.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Kiro whoami parser now validates account data from full output before trying the first line. The sign-in-state tests cover null accounts, empty or invalid output, and incomplete account data.

Changes: Kiro authentication status

Layer / File(s) Summary
Whoami parsing and authentication status
packages/provider-kiro/src/server/status.ts, packages/provider-kiro/src/server/driver.test.ts
The schema distinguishes null accounts from account objects with a required string accountType. The parser checks full output before falling back to the first line and updates authentication results. Tests cover formatted null-account responses and empty, malformed, or incomplete output.

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

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#14693: Introduced Kiro whoami handling and first-line parsing for output that includes an Identity Center Profile: block.

Suggested reviewers: juliusmarminge

Merge Risk: Minimal · up to f71d7

Kiro sign-in detection now confirms authentication only for valid account output, which avoids unintended browser login prompts. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(kiro): validate whoami output before reporting authentication" matches the main change. The status.ts change makes kiroAuthFromWhoami decode whole output and report unknown for invalid …
Description check Passed The description covers the problem (false authenticated results from empty, malformed, or account-less whoami output, and whitespace-sensitive signed-out detection), the change, the reason it matters …
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.
Full details: Title check

Explanation

The title "fix(kiro): validate whoami output before reporting authentication" matches the main change. The status.ts change makes kiroAuthFromWhoami decode whole output and report unknown for invalid or account-less output, and the driver test covers these cases. It is a conventional commit title in plain language, and the title and PR objectives agree.

Full details: Description check

Explanation

The description covers the problem (false authenticated results from empty, malformed, or account-less whoami output, and whitespace-sensitive signed-out detection), the change, the reason it matters (model and agent discovery is gated on authentication), and verification with focused test commands and results. It follows the template's Problem, Change, Verification sections. It has no explicit Scope section linking an issue or explaining why no issue is needed, and it does not state the bug is an obvious small fix. That gap is non-critical, so the check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9d28fc9 and f71d7a8.

Files selected for processing: 2

  • packages/provider-kiro/src/server/driver.test.ts
  • packages/provider-kiro/src/server/status.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.

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant