Hmbown/CodeWhale · error
cloud agent created but its labels could not be applied
Error message
cloud agent created but its labels could not be applied ({}); the sandbox was torn down — retry the job. What it means
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.
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
Defensive patterns
Strategy: retry
Try / catch
match dispatch(job) {
Err(e) if e.to_string().contains("torn down — retry") => retry_with_backoff(job),
other => other,
} Prevention
- Retry transient provisioning failures automatically with backoff
- Check Daytona status before bulk dispatches
- Avoid dispatching with soon-to-expire credentials
When it happens
Trigger: `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.
Common situations: Transient Daytona label-endpoint failure or rate limit right after create; expired credentials mid-provisioning; sandbox reaped between create and label.
Related errors
- cloud agent label apply failed
- Cloud agent create failed
- Cloud agent create succeeded but returned no usable sandbox…
- Cloud agent sandbox disappeared before it was ready.
- Cloud agent sandbox entered state
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/9b68e943763be98e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/cloud_dispatch.rs:1566
// fails truthfully — no orphan, retryable — rather than returning
// a receipt the reconciler can never find again.
if let Err(label_error) = Self::put_sandbox_labels(&sandbox_id, &api_key, job) {
let undo = Self::send_json(
reqwest::Method::DELETE,
&Self::control_plane_url(&format!("sandbox/{sandbox_id}"))?,
&api_key,
serde_json::Value::Null,
)
.and_then(|response| {
let status = response.status();
if status.is_success() || status.as_u16() == 404 {
Ok(())
} else {
bail!("HTTP {status}")
}
});
match undo {
Ok(()) => bail!(
"cloud agent created but its labels could not be applied ({}); \
the sandbox was torn down — retry the job.",
sanitize_error(&label_error.to_string())
),
Err(undo_error) => bail!(
"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.",
sanitize_error(&label_error.to_string()),
sanitize_error(&undo_error.to_string())
),
}
}
Ok(SandboxReceipt {
sandbox_id,
toolbox_url,
})
}View on GitHub (pinned to 73e0f67d83)