{"record":{"id":"51581df2b8f0958f","repo":"paperclipai/paperclip","slug":"anthropic-usage-api-returned-resp-status","errorCode":null,"errorMessage":"anthropic usage api returned ${resp.status}","messagePattern":"anthropic usage api returned (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/adapters/claude-local/src/server/quota.ts","lineNumber":281,"sourceCode":"/** fetch with an abort-based timeout so a hanging provider api doesn't block the response indefinitely */\nexport async function fetchWithTimeout(url: string, init: RequestInit, ms = 8000): Promise<Response> {\n  const controller = new AbortController();\n  const timer = setTimeout(() => controller.abort(), ms);\n  try {\n    return await fetch(url, { ...init, signal: controller.signal });\n  } finally {\n    clearTimeout(timer);\n  }\n}\n\nexport async function fetchClaudeQuota(token: string): Promise<QuotaWindow[]> {\n  const resp = await fetchWithTimeout(\"https://api.anthropic.com/api/oauth/usage\", {\n    headers: {\n      Authorization: `Bearer ${token}`,\n      \"anthropic-beta\": \"oauth-2025-04-20\",\n    },\n  });\n  if (!resp.ok) throw new Error(`anthropic usage api returned ${resp.status}`);\n  const body = (await resp.json()) as AnthropicUsageResponse;\n  const windows: QuotaWindow[] = [];\n\n  if (body.five_hour != null) {\n    windows.push({\n      label: \"Current session\",\n      usedPercent: toPercent(body.five_hour.utilization),\n      resetsAt: body.five_hour.resets_at ?? null,\n      valueLabel: null,\n      detail: null,\n    });\n  }\n  if (body.seven_day != null) {\n    windows.push({\n      label: \"Current week (all models)\",\n      usedPercent: toPercent(body.seven_day.utilization),\n      resetsAt: body.seven_day.resets_at ?? null,\n      valueLabel: null,","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/paperclipai/paperclip/blob/3f1d897a7c018d76563a21c6e39c3c9b03933622/packages/adapters/claude-local/src/server/quota.ts#L263-L299","documentation":"Error \"anthropic usage api returned ${resp.status}\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/adapters/claude-local/src/server/quota.ts:219 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry later; the usage API returned an error status.","Re-authenticate (`claude login`) if the status indicates auth failure."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3f1d897a7c018d76563a21c6e39c3c9b03933622","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}