{"record":{"id":"27bfa2b16ec1e910","repo":"Hmbown/CodeWhale","slug":"http-status","errorCode":null,"errorMessage":"HTTP {status}","messagePattern":"HTTP \\{status\\}","errorType":"http","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1562,"sourceCode":"        // (kept there for forward compatibility). Labels are load-bearing:\n        // the orphan reconciler joins them back to job records, so a\n        // sandbox without them is untraceable spend. If the PUT fails, the\n        // already-created sandbox is torn down immediately and create\n        // 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 {","sourceCodeStart":1544,"sourceCodeEnd":1580,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1544-L1580","documentation":"During rollback after a label-apply failure, the DELETE teardown call returned a non-success status other than 404 (404 is accepted as already-gone). This intermediate error only controls which final message is emitted: teardown succeeded vs. needs manual cleanup.","triggerScenarios":"Compensation DELETE of the just-created sandbox hits 401/403 (bad API key), 409/5xx provider trouble, or a network failure — anything not success or 404.","commonSituations":"API key lacks delete permission, Daytona outage during rollback, sandbox already in a state that refuses deletion.","solutions":["Check the inner HTTP status and the API key's permissions","Look in the Daytona dashboard for the sandbox id named in the final error and delete it manually","Retry teardown once the provider recovers"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure the key can delete sandboxes before dispatch begins\ncheck_permission(key, \"sandbox:delete\")?;","typeGuard":null,"tryCatchPattern":"if let Err(undo_error) = teardown(sandbox_id, key) {\n    error!(\"manual cleanup required for sandbox {sandbox_id}: {undo_error}\");\n    notify_operator(sandbox_id);\n}","preventionTips":["Grant the dispatch API key full sandbox lifecycle permissions","Retain the sandbox id in the job record so orphans can be found later","Periodically sweep for unlabelled sandboxes at the provider"],"tags":["http","cleanup","rollback","daytona"],"backgroundTag":"http-error-response","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}