Hmbown/CodeWhale · error
Codewhale account request failed
Error message
Codewhale account request failed (HTTP {}, code {code}) What it means
A request to the Codewhale account API returned a non-success HTTP status, and the response body carried a parseable machine error code string (extracted from the JSON `code` field and passed through `safe_error_code`). The CLI surfaces both the HTTP status and that error code so the developer can identify the server-side failure.
Solutions
- Read the `code` in the message and look it up in the Codewhale account API docs.
- Re-authenticate (`codewhale login`) or refresh the machine API key if the status is 401/403.
- Retry with backoff if the code indicates rate limiting (429).
- Check the Codewhale status page / contact support for 5xx statuses.
Defensive patterns
Strategy: try-catch
Try / catch
match result {
Err(e) if e.to_string().contains("HTTP 401") || e.to_string().contains("HTTP 403") => reauthenticate_and_retry(),
Err(e) if e.to_string().contains("HTTP 429") => backoff_and_retry(),
Err(e) => return Err(e),
Ok(v) => Ok(v),
} Prevention
- Refresh the account key before it expires.
- Wrap account API calls in retry-with-backoff for 429/5xx statuses.
When it happens
Trigger: Any account API call (list providers, create key, resolve models) that gets an HTTP error response whose JSON body contains a `code` string field recognized by `safe_error_code`.
Common situations: Expired/invalid account key (401/403 with an error code), rate limiting, requesting a nonexistent resource, or server-side validation errors returned as JSON with `code`.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Cloud agent sandbox listing failed
- Codewhale account request failed
- Codewhale account request failed
- Codewhale account request failed
- The Codewhale service returned HTTP
AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15).
Data as JSON: /api/errors/963fa1854aea48b9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/cloud.rs:1260
fn parse_json_body<T: DeserializeOwned>(body: &[u8]) -> Result<T> {
serde_json::from_slice(body).context("The Codewhale service returned an invalid JSON response")
}
fn response_error(response: &CloudResponse) -> anyhow::Error {
let code = serde_json::from_slice::<serde_json::Value>(&response.body)
.ok()
.and_then(|body| {
body.get("code")
.and_then(serde_json::Value::as_str)
.or_else(|| {
body.get("error")
.and_then(|error| error.get("code"))
.and_then(serde_json::Value::as_str)
})
.and_then(safe_error_code)
});
match code {
Some(code) => anyhow!(
"Codewhale account request failed (HTTP {}, code {code})",
response.status
),
None => anyhow!(
"Codewhale account request failed (HTTP {})",
response.status
),
}
}
fn safe_error_code(code: &str) -> Option<String> {
if code.is_empty()
|| code.len() > 80
|| !code
.bytes()
.all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-' | b'.'))
{
return None;View on GitHub (pinned to 433685b202)