Hmbown/CodeWhale · error

Codewhale account request failed

Error message

Codewhale account request failed (HTTP {status})

What it means

Sibling of the coded variant: when the Codewhale account API returns a non-success HTTP status but the body has no usable `code` field, the CLI raises this error with just the HTTP status. It is the fallback branch of the same match as error 1532.

Solutions

  1. Check the HTTP status: 401/403 → re-authenticate with `codewhale login` or a fresh API key.
  2. For 5xx, retry later or check service status; a proxy/CDN is likely stripping the error body.
  3. Inspect connectivity: corporate proxies or VPNs may intercept account API traffic.
Defensive patterns

Strategy: retry

Try / catch

// bare-status errors are often 5xx from proxies
match result {
    Err(e) if e.to_string().contains("Codewhale account request failed (HTTP 5")
        => backoff_retry(|| send_request(), 3),
    other => other,
}

Prevention

When it happens

Trigger: Any account API request returning a non-success status whose error body is non-JSON, JSON without a `code` key, or whose code failed the `safe_error_code` filter (non-string/unsafe characters).

Common situations: HTML error pages from proxies/load balancers (502/503), empty error bodies, CDN intercepting the request, service incidents returning bare statuses.

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


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/f496b61851f3d441. Report an issue: GitHub.

Appendix: source

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

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 73e0f67d83)