{"record":{"id":"d13669daf41676ff","repo":"Hmbown/CodeWhale","slug":"codewhale-account-request-failed-http","errorCode":null,"errorMessage":"Codewhale account request failed (HTTP {})","messagePattern":"Codewhale account request failed \\(HTTP (.+?)\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/cli/src/cloud.rs","lineNumber":1264,"sourceCode":"fn response_error(response: &CloudResponse) -> anyhow::Error {\n    let code = serde_json::from_slice::<serde_json::Value>(&response.body)\n        .ok()\n        .and_then(|body| {\n            body.get(\"code\")\n                .and_then(serde_json::Value::as_str)\n                .or_else(|| {\n                    body.get(\"error\")\n                        .and_then(|error| error.get(\"code\"))\n                        .and_then(serde_json::Value::as_str)\n                })\n                .and_then(safe_error_code)\n        });\n    match code {\n        Some(code) => anyhow!(\n            \"Codewhale account request failed (HTTP {}, code {code})\",\n            response.status\n        ),\n        None => anyhow!(\n            \"Codewhale account request failed (HTTP {})\",\n            response.status\n        ),\n    }\n}\n\nfn safe_error_code(code: &str) -> Option<String> {\n    if code.is_empty()\n        || code.len() > 80\n        || !code\n            .bytes()\n            .all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-' | b'.'))\n    {\n        return None;\n    }\n    Some(code.to_string())\n}\n","sourceCodeStart":1246,"sourceCodeEnd":1282,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/crates/cli/src/cloud.rs#L1246-L1282","documentation":"Variant of error 2031: the Codewhale account API returned a non-success HTTP status but no usable machine error code could be extracted from the response body (missing `code` field or code rejected by `safe_error_code`). Only the HTTP status is reported.","triggerScenarios":"Same as 2031 — any failing account API request — but the response JSON lacks a `code` string field, is not valid JSON, or the code value fails `safe_error_code`.","commonSituations":"Gateway/proxy error pages (HTML bodies), older server versions not emitting `code`, or malformed error responses during outages.","solutions":["Act on the HTTP status: 401/403 → re-authenticate; 429 → back off; 5xx → retry later.","Re-run `codewhale login` to refresh the account key.","Check network intermediaries (corporate proxies) that may replace error bodies.","Upgrade the CLI, then retry; report the raw status if it persists."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// status-only failure (no server error code): inspect status, retry transient ones\nif let Err(e) = call() {\n    let msg = e.to_string();\n    if msg.contains(\"HTTP 5\") || msg.contains(\"HTTP 429\") { retry_with_backoff(); }\n    else if msg.contains(\"HTTP 401\") || msg.contains(\"HTTP 403\") { reauth(); }\n    else { return Err(e); }\n}","preventionTips":["Handle both message variants (with and without `code`) when matching on this error.","Keep an upgrade path: older servers may not emit machine error codes."],"tags":["http","api","cloud"],"backgroundTag":"http-error-response","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}