{"record":{"id":"9b68e943763be98e","repo":"Hmbown/CodeWhale","slug":"cloud-agent-created-but-its-labels-could-not-be-applied-the","errorCode":null,"errorMessage":"cloud agent created but its labels could not be applied ({}); the sandbox was torn down — retry the job.","messagePattern":"cloud agent created but its labels could not be applied \\((.+?)\\); the sandbox was torn down — retry the job\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1566,"sourceCode":"        // fails truthfully — no orphan, retryable — rather than returning\n        // a receipt the reconciler can never find again.\n        if let Err(label_error) = Self::put_sandbox_labels(&sandbox_id, &api_key, job) {\n            let undo = Self::send_json(\n                reqwest::Method::DELETE,\n                &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    }","sourceCodeStart":1548,"sourceCodeEnd":1584,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1548-L1584","documentation":"The sandbox was created successfully but applying its job labels failed, so the library deleted the sandbox and aborts the dispatch with an instruction to retry. The wrapped message carries the sanitized original label error.","triggerScenarios":"`put_sandbox_labels` fails (any non-success status from the labels endpoint) after create succeeded, and the subsequent DELETE returns success or 404, so rollback completed.","commonSituations":"Transient Daytona label-endpoint failure or rate limit right after create; expired credentials mid-provisioning; sandbox reaped between create and label.","solutions":["Retry the job as the message advises — the failure was rolled back cleanly","If it repeats, check the label API key/permissions and Daytona service status","Reduce parallel dispatch volume if hitting 429"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match dispatch(job) {\n    Err(e) if e.to_string().contains(\"torn down — retry\") => retry_with_backoff(job),\n    other => other,\n}","preventionTips":["Retry transient provisioning failures automatically with backoff","Check Daytona status before bulk dispatches","Avoid dispatching with soon-to-expire credentials"],"tags":["cloud","daytona","labels","retryable"],"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"}