{"record":{"id":"abaa2bd69bbe6e7d","repo":"diegosouzapw/OmniRoute","slug":"kiro-credits-api-error-response-status-err","errorCode":null,"errorMessage":"Kiro credits API error (${response.status}): ${errText}","messagePattern":"Kiro credits API error \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/usage/fetcher.ts","lineNumber":441,"sourceCode":" * The endpoint mirrors what Kiro IDE uses internally for the credit badge.\n */\nasync function getKiroUsage(accessToken: string) {\n  try {\n    const response = await fetch(\"https://codewhisperer.us-east-1.amazonaws.com/getUserCredits\", {\n      method: \"GET\",\n      headers: {\n        Authorization: `Bearer ${accessToken}`,\n        ...getKiroServiceHeaders(\"application/json\"),\n      },\n    });\n\n    if (!response.ok) {\n      const errText = await response.text();\n      // 401/403 = expired token, show user-friendly message\n      if (response.status === 401 || response.status === 403) {\n        return { message: \"Kiro token expired. Please reconnect in Dashboard → Providers → Kiro.\" };\n      }\n      throw new Error(`Kiro credits API error (${response.status}): ${errText}`);\n    }\n\n    const data = await response.json();\n\n    // Response shape: { remainingCredits, totalCredits, resetDate, subscriptionType }\n    const remaining = data.remainingCredits ?? data.remaining_credits ?? null;\n    const total = data.totalCredits ?? data.total_credits ?? null;\n    const resetDate = data.resetDate ?? data.reset_date ?? null;\n    const plan = data.subscriptionType ?? data.subscription_type ?? \"unknown\";\n\n    if (remaining === null) {\n      return { message: \"Kiro connected. Credit data unavailable — check Kiro IDE for balance.\" };\n    }\n\n    return {\n      plan,\n      credits: {\n        remaining,","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/usage/fetcher.ts#L423-L459","documentation":"Error \"Kiro credits API error (${response.status}): ${errText}\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/usage/fetcher.ts:441 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}