{"record":{"id":"a2ed6af64b83bbcd","repo":"Hmbown/CodeWhale","slug":"cloud-agent-repository-clone-failed-http-status","errorCode":null,"errorMessage":"Cloud agent repository clone failed (HTTP {status}).","messagePattern":"Cloud agent repository clone failed \\(HTTP (.+?)\\)\\.","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1636,"sourceCode":"                    if response.status().as_u16() == 404 {\n                        bail!(\"Cloud agent sandbox disappeared before it was ready.\");\n                    }\n                }\n            }\n            std::thread::sleep(READY_POLL_INTERVAL);\n        }\n        bail!(\"Cloud agent sandbox was not ready in time.\");\n    }\n\n    fn clone_repository(&self, receipt: &SandboxReceipt, repo_url: &str, path: &str) -> Result<()> {\n        let repo_url = validate_git_remote_url(repo_url)?;\n        let api_key = Self::api_key()?;\n        let url = Self::toolbox_base(receipt)?.join(\"git/clone\")?;\n        let body = serde_json::json!({ \"url\": repo_url, \"path\": path });\n        let response = Self::send_json(reqwest::Method::POST, &url, &api_key, body)?;\n        let status = response.status();\n        if !status.is_success() {\n            bail!(\"Cloud agent repository clone failed (HTTP {status}).\");\n        }\n        Ok(())\n    }\n\n    fn run_harness(&self, receipt: &SandboxReceipt, command: &HarnessCommand) -> Result<String> {\n        let api_key = Self::api_key()?;\n        let url = Self::toolbox_base(receipt)?.join(\"process/execute\")?;\n        // The toolbox executes one shell command string, so every argv\n        // element is POSIX-single-quoted — a prompt cannot interpolate.\n        let body = serde_json::json!({\n            \"command\": shell_quote_join(&command.argv),\n            \"cwd\": command.cwd,\n            \"timeout\": command.timeout_secs,\n        });\n        // This call carries the declared turn budget (an hour for the agent\n        // entry), so it asks for that budget plus slack per request — never the\n        // 120s control-plane cap that used to bound it.\n        let response = Self::send_json_on(","sourceCodeStart":1618,"sourceCodeEnd":1654,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1618-L1654","documentation":"Thrown by `clone_repository` when the sandbox toolbox HTTP endpoint `POST git/clone` returns a non-2xx status. The dispatcher already validated the remote URL and sent `{url, path}` to the sandbox; the sandbox itself refused or failed the clone. The provider HTTP status is surfaced in the message so the developer can distinguish auth (401/403), bad request (400/422), and server-side failures (5xx).","triggerScenarios":"Any cloud-agent run that clones a repository into the sandbox when the toolbox `git/clone` call fails: invalid or unauthorized repo URL (private repo without credentials the sandbox can use), nonexistent repo/ref, unwritable target path inside the sandbox, or toolbox returning 5xx.","commonSituations":"Cloning a private repository the sandbox token cannot read; typo'd or renamed repo URL; the target `path` already exists or is not writable; large monorepo clone timing out at the toolbox; sandbox disk quota exceeded (507/5xx).","solutions":["Read the HTTP status in the message: 401/403 means supply repository credentials the sandbox can use (deploy key/token in the remote URL via validate_git_remote_url-accepted forms); 404 means the repo URL is wrong or private.","Verify the repo URL is reachable and the correct branch/ref exists; test `git ls-remote <url>` locally.","Retry the job if the status is 5xx — the sandbox toolbox may have been temporarily unhealthy.","Ensure the target clone path inside SANDBOX_WORKSPACE is not pre-occupied; a stale sandbox from a prior run may still hold the path — tear it down and retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// pre-flight: confirm the repo is reachable before dispatching the cloud job\nlet out = std::process::Command::new(\"git\")\n    .args([\"ls-remote\", repo_url])\n    .output()?;\nif !out.status.success() {\n    anyhow::bail!(\"repo URL unreachable before cloud dispatch: {}\", String::from_utf8_lossy(&out.stderr));\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"clone failed (HTTP 4\") => show(\"check repo URL / credentials for the sandbox\"),\n    Err(e) if e.to_string().contains(\"clone failed (HTTP 5\") => retry_with_backoff(job, 2),\n    other => other,\n}","preventionTips":["Validate the remote URL and access with `git ls-remote` before dispatching.","Provision sandbox credentials (deploy key/PAT) for private repos ahead of the clone.","Use a clean sandbox per job so a stale clone path cannot collide.","Check status codes: 4xx = URL/credentials problem, 5xx = provider problem."],"tags":["http","git","cloud","sandbox"],"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-22T21:17:16.096Z"}