{"record":{"id":"56f2b013f739da59","repo":"paperclipai/paperclip","slug":"chatgpt-wham-api-returned-resp-status","errorCode":null,"errorMessage":"chatgpt wham api returned ${resp.status}","messagePattern":"chatgpt wham api returned (.+?)","errorType":"exception","errorClass":"CodexQuotaAuthError","httpStatus":null,"severity":"error","filePath":"packages/adapters/codex-local/src/server/quota.ts","lineNumber":295,"sourceCode":"}\n\nexport async function fetchCodexQuota(\n  token: string,\n  accountId: string | null,\n): Promise<QuotaWindow[]> {\n  const headers: Record<string, string> = {\n    Authorization: `Bearer ${token}`,\n  };\n  if (accountId) headers[\"ChatGPT-Account-Id\"] = accountId;\n\n  const resp = await fetchWithTimeout(\"https://chatgpt.com/backend-api/wham/usage\", { headers });\n  if (!resp.ok) {\n    const message = `chatgpt wham api returned ${resp.status}`;\n    const responseText = await readResponseTextPrefix(resp);\n    const authFailure = classifyCodexAuthRefreshFailure({\n      errorMessage: [message, responseText].filter(Boolean).join(\"\\n\"),\n    });\n    if (authFailure) throw new CodexQuotaAuthError(message, authFailure);\n    throw new Error(message);\n  }\n  const body = (await resp.json()) as WhamUsageResponse;\n  const windows: QuotaWindow[] = [];\n\n  const rateLimit = body.rate_limit;\n  if (rateLimit?.primary_window != null) {\n    const w = rateLimit.primary_window;\n    windows.push({\n      label: \"5h limit\",\n      usedPercent: normalizeCodexUsedPercent(w.used_percent),\n      resetsAt:\n        typeof w.reset_at === \"number\"\n          ? unixSecondsToIso(w.reset_at)\n          : (w.reset_at ?? null),\n      valueLabel: null,\n      detail: null,\n    });","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/packages/adapters/codex-local/src/server/quota.ts#L277-L313","documentation":"Error \"chatgpt wham api returned ${resp.status}\" thrown in paperclipai/paperclip.","triggerScenarios":"Thrown at packages/adapters/codex-local/src/server/quota.ts:295 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry later; the quota API returned an error status.","Re-authenticate Codex if the status indicates auth failure."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}