{"record":{"id":"9561000704a3a068","repo":"Hmbown/CodeWhale","slug":"cloud-agent-create-failed-http-status","errorCode":null,"errorMessage":"Cloud agent create failed (HTTP {status}).","messagePattern":"Cloud agent create failed \\(HTTP (.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1499,"sourceCode":"            .bearer_auth(api_key)\n            .json(&body)\n            .send()\n            .context(\"could not reach the cloud agent service\")\n    }\n}\n\nimpl DaytonaLauncher for LiveDaytonaLauncher {\n    fn create_sandbox(&self, job: &CloudJob) -> Result<SandboxReceipt> {\n        let api_key = Self::api_key()?;\n        let url = Self::control_plane_url(\"sandbox\")?;\n        let machine_token =\n            read_cloud_agent_token().ok_or_else(|| anyhow!(missing_machine_token_message()))?;\n        let body = create_sandbox_body(job, &machine_token, &cloud_agent_snapshot());\n        let response = Self::send_json(reqwest::Method::POST, &url, &api_key, body)?;\n        let status = response.status();\n        let text = response.text().unwrap_or_default();\n        if !status.is_success() {\n            bail!(\"Cloud agent create failed (HTTP {status}).\");\n        }\n        let parsed: serde_json::Value =\n            serde_json::from_str(&text).context(\"the cloud agent service returned invalid JSON\")?;\n        let sandbox_id = parsed\n            .get(\"id\")\n            .or_else(|| parsed.get(\"sandboxId\"))\n            .and_then(serde_json::Value::as_str)\n            .unwrap_or(\"\")\n            .trim()\n            .to_string();\n        if !valid_sandbox_id(&sandbox_id) {\n            // The provider says the sandbox exists (2xx) but gave us an id\n            // we cannot safely interpolate into a path, so explicit teardown\n            // is impossible. Best-effort delete with the raw string when it\n            // is at least non-empty (the DELETE path itself validates and\n            // will refuse dangerous shapes), and always name it in the\n            // error so an operator can clean it up.\n            let raw = parsed","sourceCodeStart":1481,"sourceCodeEnd":1517,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1481-L1517","documentation":"The POST to Daytona's sandbox create endpoint returned a non-success HTTP status; the response body is discarded (only the status is reported). This is the primary provisioning call for a cloud agent sandbox, so failure means no sandbox exists and the job cannot start.","triggerScenarios":"`send_json(POST, url, ...)` returns 401/403 (bad machine token or API key), 400 (invalid create body), 402/quota (out of sandbox credits), 429, or 5xx from Daytona.","commonSituations":"Missing or expired cloud agent machine token, exhausted Daytona quota/billing, malformed job payload after a protocol change, provider outage.","solutions":["Read the actual HTTP status; if 401/403 re-authenticate or refresh the machine token","Check Daytona quota/billing if 402/429","Retry on 5xx/transient failures","Compare the create body against the current Daytona API if 400"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-flight: require a machine token and api key before attempting create\nlet token = read_cloud_agent_token().ok_or_else(|| anyhow!(\"no machine token\"))?;\nlet key = Self::api_key()?;","typeGuard":null,"tryCatchPattern":"match create_sandbox(job) {\n    Err(e) if e.to_string().contains(\"HTTP 5\") || e.to_string().contains(\"HTTP 429\") => retry_with_backoff(job),\n    Err(e) if e.to_string().contains(\"HTTP 4\") => bail!(\"config/auth problem: {e}\"),\n    Ok(r) => r,\n}","preventionTips":["Refresh the machine token before long dispatch sessions","Monitor Daytona quota/billing","Log response bodies on create failure for diagnosis"],"tags":["http","cloud","daytona","provisioning"],"backgroundTag":"api-error-response","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T21:17:16.096Z"}