{"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":1029,"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":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/crates/cli/src/cloud.rs#L1011-L1047","documentation":"Same account-API failure path, but the response body had no usable code (absent, non-string, or filtered out by safe_error_code), so only the HTTP status is reported. Typically means the error came from infrastructure rather than the account API itself.","triggerScenarios":"Non-2xx response with an empty or non-JSON body: gateway 502/504 HTML pages, load balancer errors, connection-reset bodies, or a code string failing the sanitizer charset.","commonSituations":"Corporate proxies intercepting requests; full outages where fronting infrastructure answers; api_base pointed at a service that swallows error bodies.","solutions":["Check Codewhale service status and retry after backoff","Reproduce with curl against the same api_base to see the raw status/body","Ensure no proxy between the CLI and the service strips response bodies","Fall back to the canonical api_base if a custom one is in play"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.account_request(&req).await {\n    Ok(resp) => Ok(resp),\n    Err(err) if err.to_string().contains(\"HTTP 50\") => retry_with_backoff(req), // infra error, body had no code\n    Err(err) => Err(err),\n}","preventionTips":["Status-only errors usually mean infrastructure (gateways/proxies) answered — check service status before debugging the CLI","Keep api_base pointed at the real service so structured error bodies survive","Alert on this variant specifically: it indicates the account API's own error contract is not being reached"],"tags":["cli","cloud","http","gateway","api-error","rust"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}