{"record":{"id":"44d7df637bd35ac8","repo":"Hmbown/CodeWhale","slug":"cloud-agent-sandbox-id-was-created-but-its-labels-could-not","errorCode":null,"errorMessage":"cloud agent {sandbox_id} was created but its labels could not be applied ({}) and teardown also failed ({}); the sandbox needs manual cleanup at the provider.","messagePattern":"cloud agent (.+?) was created but its labels could not be applied \\((.+?)\\) and teardown also failed \\((.+?)\\); the sandbox needs manual cleanup at the provider\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1571,"sourceCode":"                &Self::control_plane_url(&format!(\"sandbox/{sandbox_id}\"))?,\n                &api_key,\n                serde_json::Value::Null,\n            )\n            .and_then(|response| {\n                let status = response.status();\n                if status.is_success() || status.as_u16() == 404 {\n                    Ok(())\n                } else {\n                    bail!(\"HTTP {status}\")\n                }\n            });\n            match undo {\n                Ok(()) => bail!(\n                    \"cloud agent created but its labels could not be applied ({}); \\\n                     the sandbox was torn down — retry the job.\",\n                    sanitize_error(&label_error.to_string())\n                ),\n                Err(undo_error) => bail!(\n                    \"cloud agent {sandbox_id} was created but its labels could not be \\\n                     applied ({}) and teardown also failed ({}); the sandbox needs \\\n                     manual cleanup at the provider.\",\n                    sanitize_error(&label_error.to_string()),\n                    sanitize_error(&undo_error.to_string())\n                ),\n            }\n        }\n        Ok(SandboxReceipt {\n            sandbox_id,\n            toolbox_url,\n        })\n    }\n\n    fn wait_ready(&self, receipt: &SandboxReceipt) -> Result<()> {\n        let api_key = Self::api_key()?;\n        if !valid_sandbox_id(&receipt.sandbox_id) {\n            bail!(\"the sandbox id is not a usable path token\");","sourceCodeStart":1553,"sourceCodeEnd":1589,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1553-L1589","documentation":"Worst-case rollback outcome: the sandbox was created, label application failed, AND the teardown DELETE also failed. The sandbox is now orphaned at the provider with no job labels, so the error tells the operator to clean it up manually. Both underlying errors are included, sanitized.","triggerScenarios":"Labels PUT fails and the compensating DELETE returns a non-success status other than 404 (e.g. 403 no delete permission, 5xx outage).","commonSituations":"Daytona incident affecting both endpoints, API key scoped read/write but not delete, network partition during rollback.","solutions":["Find the sandbox id from the message in the Daytona dashboard and delete it manually","Verify the API key has sandbox delete permissions","Retry the job only after cleaning up to avoid quota drain","Check Daytona status/incidents if 5xx"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"check_permission(key, \"sandbox:delete\")?; // ensure rollback is possible before creating anything","typeGuard":null,"tryCatchPattern":"match dispatch(job) {\n    Err(e) if e.to_string().contains(\"manual cleanup\") => {\n        let id = extract_sandbox_id_from_error(&e);\n        alert_orphaned_sandbox(id);\n    }\n    other => other,\n}","preventionTips":["Ensure delete permission so rollback can always run","Track created sandbox ids durably for manual reconciliation","Sweep the provider for orphaned sandboxes on a schedule"],"tags":["cloud","daytona","orphaned-resources","cleanup"],"backgroundTag":"orphaned-resource-cleanup-required","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"}