{"record":{"id":"160bcce29d66a5cf","repo":"Hmbown/CodeWhale","slug":"cloud-agent-label-apply-failed-http-status","errorCode":null,"errorMessage":"cloud agent label apply failed (HTTP {status}).","messagePattern":"cloud agent label apply failed \\(HTTP (.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1447,"sourceCode":"    /// Apply the dispatch labels via Daytona's dedicated labels endpoint.\n    fn put_sandbox_labels(sandbox_id: &str, api_key: &str, job: &CloudJob) -> Result<()> {\n        if !valid_sandbox_id(sandbox_id) {\n            bail!(\"the sandbox id is not a usable path token\");\n        }\n        let url = Self::control_plane_url(&format!(\"sandbox/{sandbox_id}/labels\"))?;\n        let body = serde_json::json!({\n            \"labels\": {\n                SANDBOX_JOB_LABEL: job.id,\n                \"codewhale.forge\": job.forge.as_str(),\n                SANDBOX_PRODUCT_LABEL: SANDBOX_PRODUCT_VALUE,\n            }\n        });\n        let response = Self::send_json(reqwest::Method::PUT, &url, api_key, body)?;\n        let status = response.status();\n        if status.is_success() {\n            Ok(())\n        } else {\n            bail!(\"cloud agent label apply failed (HTTP {status}).\")\n        }\n    }\n\n    fn send_json(\n        method: reqwest::Method,\n        url: &reqwest::Url,\n        api_key: &str,\n        body: serde_json::Value,\n    ) -> Result<reqwest::blocking::Response> {\n        Self::send_json_on(\n            &Self::blocking_client()?,\n            Self::CONTROL_PLANE_TIMEOUT_SECS,\n            method,\n            url,\n            api_key,\n            body,\n        )\n    }","sourceCodeStart":1429,"sourceCodeEnd":1465,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1429-L1465","documentation":"Daytona's labels endpoint (PUT sandbox/{id}/labels) returned a non-success HTTP status. The library treats label application as part of sandbox provisioning: without the job labels the sandbox is unaccounted for, so this failure aborts the dispatch (and triggers teardown by the caller).","triggerScenarios":"`send_json` PUT to the labels URL succeeds at the transport level but Daytona answers 4xx/5xx — e.g. 401/403 from a bad API key, 404 because the sandbox was destroyed concurrently, 429 rate limiting, or 5xx provider outage.","commonSituations":"Expired or wrong `CLOONEST_API_KEY`-style credential, sandbox reaped between create and label, Daytona incident/maintenance window, or rate limits under many parallel dispatches.","solutions":["Check the HTTP status in the wrapped error and verify the API key is valid and has sandbox write scope","Retry the job — the code already tears the sandbox down and asks for a retry","Check Daytona service status if 5xx","Reduce dispatch concurrency if 429"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify credential before dispatch\nlet key = std::env::var(\"DAYTONA_API_KEY\").expect(\"DAYTONA_API_KEY set\");\nassert!(!key.trim().is_empty());","typeGuard":null,"tryCatchPattern":"match put_sandbox_labels(id, key, job) {\n    Err(e) if is_retryable_status(&e) => schedule_retry(job),\n    Err(e) => bail!(\"labels failed permanently: {e}\"),\n    Ok(()) => {}\n}","preventionTips":["Use an API key with sandbox write scope","Back off and retry on 429/5xx before giving up","Check Daytona status page during incident windows"],"tags":["http","cloud","daytona","labels"],"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"}