Skip to content

fix(usage): read the social-login token key in the free credit API path - #2292

Merged
kyleseaman merged 1 commit into
mainfrom
fix/usage-api-social-login-token
Aug 9, 2026
Merged

fix(usage): read the social-login token key in the free credit API path#2292
kyleseaman merged 1 commit into
mainfrom
fix/usage-api-social-login-token

Conversation

@darko-mesaros

@darko-mesaros darko-mesaros commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Problem

Users signed in via GitHub/Google social login or Identity Center (org SSO) see no credit pill in the dashboard header. The pill either shows a permanent spinner or hides entirely.

Why it matters

The credit meter is the user's primary visibility into plan usage. With #2039's correct change making the text scrape opt-in (default off), the free API path is the only zero-cost way to surface credits — and it silently fails for two of the four login classes.

Fix (symptoms → root cause → change)

Symptom: Credit pill hidden; /api/sessions/usage returns {available: false}.

Root cause: kiro_usage_api.fetch_usage_limits() searches kiro-cli's SQLite auth_kv table for bearer tokens, but only under two of the four key names kiro-cli uses:

Login method SQLite key Before After
AWS Builder ID (OIDC) kirocli:odic:token
Legacy CodeWhisperer codewhisperer:odic:token
GitHub/Google social kirocli:social:token
Identity Center (org SSO) kirocli:external-idp:token

Key names confirmed by reverse-engineering kiro-cli binary strings — all four use the same {access_token, expires_at} blob shape.

Change: Add "kirocli:social:token" and "kirocli:external-idp:token" to _SQLITE_TOKEN_KEYS. No parser or format change needed.

This does NOT revert #2039. The text scrape remains opt-in. This fixes the free API path so all login classes get credits without paying for the scrape.

Tests

  • test_social_login_token_key_is_recognized — social-key token found from kiro-cli store
  • test_external_idp_token_key_is_recognized — external-idp-key token found from kiro-cli store
  • All 78 test_kiro_usage_api.py tests pass.

Manual verification

Verified end-to-end on a real social-login host (GitHub, kiro-cli whoami → "Logged in with GitHub"):

  • Before: _candidate_tokens() → 0 candidates → fetch_usage_limits → None
  • After: _candidate_tokens() → 1 candidate (from_cli_store=True) → GetUsageLimits 200 → {credits_used: 2480.54, credits_plan: 5000.0, plan: "KIRO PRO MAX"}

Closes #2291

@darko-mesaros
darko-mesaros requested a review from a team as a code owner August 9, 2026 00:52
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Advisory design-level review of 672738aeafda12b5db33ab7e6a3bf3b272833a35 — updated in place on each push; does not block merge.

Design-Verdict: PASS

Root-cause data fix in the mechanism's designated extension point — new keys in _SQLITE_TOKEN_KEYS flow through the existing audited, fail-closed reader unchanged.

Watch

End-to-end verification covers only the social path; the Identity Center claim rests on the shared blob shape plus the "kiro-cli's own store needs no profile ARN" trust rule in _Candidate — if an org-SSO account's GetUsageLimits call does require a profile ARN, that login class stays broken despite the key now being read. Worth one manual check on an Identity Center host before closing #2291 for that class.

[DESIGN-REVIEWED] 672738a

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 672738aeafda12b5db33ab7e6a3bf3b272833a35 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 672738a

Verdict parsed from the review's SHA-scoped output markers for commit 672738aeafda12b5db33ab7e6a3bf3b272833a35.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 672738aeafda12b5db33ab7e6a3bf3b272833a35: <one-sentence reason>

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 672738aeafda12b5db33ab7e6a3bf3b272833a35 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 672738a

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 672738aeafda12b5db33ab7e6a3bf3b272833a35: <one-sentence reason>

The kiro_usage_api module's _SQLITE_TOKEN_KEYS tuple only contained the
OIDC and legacy CodeWhisperer keys. Users signed in via GitHub social
login store their bearer token under kirocli:social:token, which was
never searched -- leaving the free GetUsageLimits path non-functional for
this login class. Since #2039 made the text scrape opt-in (default off),
these users see no credit pill at all.

Add kirocli:social:token to the key list. The token blob has the same
{access_token, expires_at} shape the existing parser expects; no format
change is needed. Verified end-to-end on a real social-login host.

Closes #2291
@darko-mesaros
darko-mesaros force-pushed the fix/usage-api-social-login-token branch from 12b7509 to 672738a Compare August 9, 2026 00:58
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Aug 9, 2026
@kyleseaman
kyleseaman merged commit 2fded82 into main Aug 9, 2026
80 of 82 checks passed
@kyleseaman
kyleseaman deleted the fix/usage-api-social-login-token branch August 9, 2026 01:32
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Aug 9, 2026
encomjp pushed a commit to encomjp/kirocrew-customapi that referenced this pull request Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Credit pill free API path does not read the social-login token key

3 participants