Hmbown/CodeWhale · error

Codewhale account request failed (HTTP {})

Error message

Codewhale account request failed (HTTP {})

What it means

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.

Source

Thrown at crates/cli/src/cloud.rs:1029

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;
    }
    Some(code.to_string())
}

View on GitHub (pinned to 8880682c63)

Solutions

  1. Check Codewhale service status and retry after backoff
  2. Reproduce with curl against the same api_base to see the raw status/body
  3. Ensure no proxy between the CLI and the service strips response bodies
  4. Fall back to the canonical api_base if a custom one is in play
Defensive patterns

Strategy: retry

Try / catch

match client.account_request(&req).await {
    Ok(resp) => Ok(resp),
    Err(err) if err.to_string().contains("HTTP 50") => retry_with_backoff(req), // infra error, body had no code
    Err(err) => Err(err),
}

Prevention

When it happens

Trigger: 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.

Common situations: Corporate proxies intercepting requests; full outages where fronting infrastructure answers; api_base pointed at a service that swallows error bodies.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/d13669daf41676ff. Report an issue: GitHub.