fix(oauth): treat Kiro social poll status as alias of error for pending states (#10620)

Kiro's device poll endpoint reports progress in a `status` field (e.g.
`authorization_pending`), but `classifyKiroSocialPoll()` only inspected
`data.error`. This caused every pre-authorization poll to fall through to
the terminal `invalid_token_response` error, making social login impossible
for Kiro AI and Amazon Q via Google/GitHub.

Changes:
- Add `status` field to `KiroSocialPollData` type
- Update `classifyKiroSocialPoll()` to check `data.status` as fallback
  for `data.error` when detecting pending states
- Add tests covering `status`-based pending detection and precedence

Closes #10618
This commit is contained in:
Krishna lokhande
2026-08-18 19:23:29 +05:30
committed by GitHub
parent 5a44c46b1d
commit 671aa3d80d
2 changed files with 25 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
export type KiroSocialPollData = {
error?: unknown;
/** Kiro reports poll progress here (e.g. "authorization_pending"), not in `error`. */
status?: unknown;
accessToken?: unknown;
refreshToken?: unknown;
};
@@ -26,8 +28,9 @@ export function classifyKiroSocialPoll(
responseStatus: number,
data: KiroSocialPollData
): KiroSocialPollOutcome {
if (data.error === "authorization_pending" || data.error === "slow_down") {
return { kind: "pending", error: data.error };
const progress = data.error ?? data.status;
if (progress === "authorization_pending" || progress === "slow_down") {
return { kind: "pending", error: progress as "authorization_pending" | "slow_down" };
}
if (!responseOk || data.error) {

View File

@@ -21,6 +21,26 @@ test("classifyKiroSocialPoll keeps only documented pending states retryable", ()
});
});
test("classifyKiroSocialPoll treats status as alias of error for pending states", () => {
// Kiro upstream returns progress in `status`, not `error`
assert.deepEqual(classifyKiroSocialPoll(true, 200, { status: "authorization_pending" }), {
kind: "pending",
error: "authorization_pending",
});
assert.deepEqual(classifyKiroSocialPoll(true, 200, { status: "slow_down" }), {
kind: "pending",
error: "slow_down",
});
// error takes precedence over status if both present
assert.deepEqual(
classifyKiroSocialPoll(true, 200, { error: "slow_down", status: "authorization_pending" }),
{
kind: "pending",
error: "slow_down",
}
);
});
test("classifyKiroSocialPoll stops on denied, expired and malformed responses", () => {
assert.deepEqual(classifyKiroSocialPoll(false, 403, { error: "access_denied" }), {
kind: "error",