{"record":{"id":"d46f25f2594c93e0","repo":"Hmbown/CodeWhale","slug":"cloud-agent-sandbox-disappeared-before-it-was-ready","errorCode":null,"errorMessage":"Cloud agent sandbox disappeared before it was ready.","messagePattern":"Cloud agent sandbox disappeared before it was ready\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1619,"sourceCode":"                    let text = response.text().unwrap_or_default();\n                    if let Ok(parsed) = serde_json::from_str::<serde_json::Value>(&text)\n                        && let Some(state) = parsed.get(\"state\").and_then(|v| v.as_str())\n                    {\n                        match state {\n                            \"started\" | \"ready\" => return Ok(()),\n                            \"error\" | \"destroyed\" | \"archived\" => {\n                                bail!(\"Cloud agent sandbox entered state '{state}'.\");\n                            }\n                            _ => {}\n                        }\n                    } else {\n                        return Ok(());\n                    }\n                }\n                Err(error) => return Err(error),\n                Ok(response) => {\n                    if response.status().as_u16() == 404 {\n                        bail!(\"Cloud agent sandbox disappeared before it was ready.\");\n                    }\n                }\n            }\n            std::thread::sleep(READY_POLL_INTERVAL);\n        }\n        bail!(\"Cloud agent sandbox was not ready in time.\");\n    }\n\n    fn clone_repository(&self, receipt: &SandboxReceipt, repo_url: &str, path: &str) -> Result<()> {\n        let repo_url = validate_git_remote_url(repo_url)?;\n        let api_key = Self::api_key()?;\n        let url = Self::toolbox_base(receipt)?.join(\"git/clone\")?;\n        let body = serde_json::json!({ \"url\": repo_url, \"path\": path });\n        let response = Self::send_json(reqwest::Method::POST, &url, &api_key, body)?;\n        let status = response.status();\n        if !status.is_success() {\n            bail!(\"Cloud agent repository clone failed (HTTP {status}).\");\n        }","sourceCodeStart":1601,"sourceCodeEnd":1637,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1601-L1637","documentation":"During the readiness poll the provider answered 404, meaning the sandbox no longer exists even though create had succeeded moments earlier. Waiting is pointless, so the library fails fast with this message.","triggerScenarios":"A GET on sandbox/{id} returns 404 during the READY_POLL_ATTEMPTS loop — the sandbox was destroyed externally, failed provisioning and was reaped, or the id is scoped to another project/region than the API key.","commonSituations":"Provider auto-reaping failed sandboxes, concurrent teardown by another job/agent, API key pointing at a different Daytona workspace than the one that created the sandbox.","solutions":["Re-dispatch the job to create a new sandbox","Verify the API key/workspace matches the one used at create time","Check the Daytona dashboard and audit logs for who deleted the sandbox","Look for concurrent jobs operating on the same sandbox id"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure the same workspace/key is used for create and poll\nassert_eq!(api_key_workspace(&create_key), api_key_workspace(&poll_key));","typeGuard":null,"tryCatchPattern":"match wait_ready(&receipt) {\n    Err(e) if e.to_string().contains(\"disappeared\") => re_dispatch(job),\n    Err(e) => bail!(e),\n    Ok(()) => {}\n}","preventionTips":["Use one API key/workspace consistently across create, label, and poll","Avoid running concurrent jobs against the same sandbox id","Check for provider auto-reaping policies on failed sandboxes"],"tags":["cloud","daytona","sandbox","resource-not-found"],"backgroundTag":"resource-not-found","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"}