{"record":{"id":"70af930601ec665b","repo":"Hmbown/CodeWhale","slug":"could-not-reach-the-codewhale-service","errorCode":null,"errorMessage":"Could not reach the Codewhale service: {}","messagePattern":"Could not reach the Codewhale service: (.+?)","errorType":"exception","errorClass":"MachineError","httpStatus":null,"severity":"error","filePath":"crates/cli/src/cloud/machine.rs","lineNumber":719,"sourceCode":"    retry: Retry,\n    sleeper: &mut dyn FnMut(Duration),\n    build: impl Fn() -> CloudRequest,\n) -> Result<CloudResponse> {\n    let max_attempts = if retry == Retry::Idempotent {\n        MAX_ATTEMPTS\n    } else {\n        1\n    };\n    let mut attempt = 1;\n    loop {\n        let (error, retry_after) = match transport.execute(build()) {\n            Ok(response) if (200..300).contains(&response.status) => return Ok(response),\n            Ok(response) => {\n                let retry_after = response.retry_after;\n                (classify(&response), retry_after)\n            }\n            Err(err) => (\n                MachineError::transport(format!(\n                    \"Could not reach the Codewhale service: {}\",\n                    printable(&err.to_string())\n                )),\n                None,\n            ),\n        };\n        if !error.retryable || attempt >= max_attempts {\n            return Err(anyhow::Error::new(error));\n        }\n        sleeper(backoff_delay(attempt, retry_after));\n        attempt += 1;\n    }\n}\n\nfn decode_json<R: serde::de::DeserializeOwned>(response: CloudResponse) -> Result<R> {\n    serde_json::from_slice(&response.body)\n        .context(\"The Codewhale service returned an invalid JSON response\")\n}","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/cli/src/cloud/machine.rs#L701-L737","documentation":"send_with_retry wraps cloud transport calls; when transport.execute returns Err (no HTTP response at all — DNS failure, refused connection, TLS error, timeout at the transport layer), it builds a transport MachineError with this message. Idempotent requests are retried with backoff before the error surfaces.","triggerScenarios":"Any cloud API call (e.g. get_json) when the machine cannot connect to the Codewhale service: service down, wrong base URL, DNS failure, firewall, TLS handshake failure, or local network outage.","commonSituations":"Offline development; corporate proxies blocking the endpoint; mistyped CODEWHALE service URL; service outage during `codewhale account` operations.","solutions":["Check network connectivity and that the Codewhale service URL is correct","Verify the service is up (status page or health endpoint)","Check proxy/VPN/firewall settings and TLS certificates","Retry later if it is a transient outage — idempotent calls already retry with backoff"],"exampleFix":"// ensure base URL is reachable before calling\nlet url = std::env::var(\"CODEWHALE_SERVICE_URL\")?;\nreqwest::get(format!(\"{url}/health\")).await\n    .context(\"Codewhale service unreachable — check URL/network\")?;","handlingStrategy":"retry","validationCode":"// pre-flight reachability check\nreqwest::get(format!(\"{base}/health\")).await.map_err(|e| format!(\"service unreachable: {e}\"))?;","typeGuard":null,"tryCatchPattern":"match send_with_retry(...) {\n    Ok(resp) => resp,\n    Err(e) if e.to_string().contains(\"Could not reach the Codewhale service\") => {\n        // transport-layer failure: check connectivity, then retry or fail gracefully\n        eprintln!(\"offline or wrong service URL; retry later\");\n        default_value\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Check network/VPN before cloud operations","Confirm the service base URL configuration","Rely on idempotent-retry semantics; make requests idempotent where possible","Monitor service status during outages"],"tags":["network","http","cloud","connectivity"],"backgroundTag":"connection-refused","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}