{"record":{"id":"06588df9dc06f5f7","repo":"Hmbown/CodeWhale","slug":"cloud-agent-produced-no-branch-head-to-raise","errorCode":null,"errorMessage":"Cloud agent produced no branch head to raise.","messagePattern":"Cloud agent produced no branch head to raise\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/cloud_dispatch.rs","lineNumber":1749,"sourceCode":"                },\n            )?\n            .trim()\n            .to_string();\n        let patch = self.run_harness(\n            receipt,\n            &HarnessCommand {\n                argv: vec![\n                    \"git\".to_string(),\n                    \"format-patch\".to_string(),\n                    \"origin/HEAD..HEAD\".to_string(),\n                    \"--stdout\".to_string(),\n                ],\n                cwd: SANDBOX_WORKSPACE.to_string(),\n                timeout_secs: 60,\n            },\n        )?;\n        if base_branch.is_empty() || head_sha.len() < 7 {\n            bail!(\"Cloud agent produced no branch head to raise.\");\n        }\n        if patch.trim().is_empty() {\n            bail!(\"Cloud agent produced an empty patch; refusing to open a PR.\");\n        }\n        Ok(PatchReceipt {\n            base_branch,\n            head_sha,\n            summary,\n            patch,\n        })\n    }\n\n    fn teardown(&self, receipt: &SandboxReceipt) -> Result<()> {\n        let api_key = Self::api_key()?;\n        if !valid_sandbox_id(&receipt.sandbox_id) {\n            bail!(\"the sandbox id is not a usable path token\");\n        }\n        let url = Self::control_plane_url(&format!(\"sandbox/{}\", receipt.sandbox_id))?;","sourceCodeStart":1731,"sourceCodeEnd":1767,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/cloud_dispatch.rs#L1731-L1767","documentation":"Thrown while raising a PR after the patch-extraction harness runs: the dispatcher asked the sandbox for the base branch name and the head SHA of the agent's work, and the response was empty (`base_branch` empty) or the head SHA shorter than 7 characters. Without a resolvable head commit there is nothing to push or open a PR from, so the operation aborts before any remote call.","triggerScenarios":"Completing a cloud-agent job whose workspace has no commits distinct from the base: the agent made no commits, committed on a detached HEAD the extraction script could not resolve, or `git rev-parse HEAD` returned empty inside a repo with zero commits.","commonSituations":"Agent finished analysis but never wrote/committed changes; the agent committed but on the wrong branch so the extraction query returned empty; git identity not configured in the sandbox so commits silently failed earlier (surfacing only here); corrupted or non-git workspace path.","solutions":["Check the harness output/logs to see whether the agent actually made commits; if the task legitimately produced no change, treat the job as no-op rather than retrying.","Ensure the agent's commit step succeeds: configure git user.email/user.name in the sandbox setup and commit on a named work branch.","Verify SANDBOX_WORKSPACE is the directory the agent actually wrote to; a cwd mismatch leaves the extraction repo empty.","Retry the job if the sandbox state was flaky (e.g. the clone only partially completed)."],"exampleFix":"// sandbox setup harness: ensure identity and a work branch before the agent runs\n[\"bash\", \"-lc\", \"git config user.email agent@example.com && git config user.name agent && git checkout -b work\"],","handlingStrategy":"validation","validationCode":"// before raising a PR, confirm the sandbox workspace actually has a distinct head\nlet head = run_harness(&receipt, &HarnessCommand {\n    argv: vec![\"bash\", \"-lc\", \"git rev-parse HEAD 2>/dev/null || true\"],\n    cwd: SANDBOX_WORKSPACE.into(), timeout_secs: 30,\n})?;\nif head.trim().len() < 7 { /* agent made no commits — skip PR */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure git user.email/user.name in the sandbox setup so agent commits never silently fail.","Have the agent commit on a named work branch, not detached HEAD.","Ensure the agent's cwd is the cloned repo inside SANDBOX_WORKSPACE.","Treat 'no commits' as a legitimate no-op outcome rather than an error loop."],"tags":["git","cloud","pr","invariant"],"backgroundTag":"empty-required-field","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"}