{"record":{"id":"c1a78316fa10341f","repo":"Hmbown/CodeWhale","slug":"git-archive-origin-main-failed","errorCode":null,"errorMessage":"git archive origin/main failed: {}","messagePattern":"git archive origin/main failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/operate.rs","lineNumber":893,"sourceCode":"    fs::create_dir_all(&dest).with_context(|| format!(\"Failed to create {}\", dest.display()))?;\n    let archive = Command::new(\"git\")\n        .arg(\"-C\")\n        .arg(&repo)\n        .args([\n            \"archive\",\n            \"origin/main\",\n            \"--\",\n            \"DIRECTION.md\",\n            CHECK_AUTO_MERGE_SCRIPT,\n            AUTO_MERGE_SCRIPT,\n            AUTO_MERGE_PR_SCRIPT,\n            \"agent-workstreams/AUTO_MERGE.toml\",\n        ])\n        .stdin(Stdio::null())\n        .output()\n        .context(\"git archive origin/main\")?;\n    if !archive.status.success() {\n        anyhow::bail!(\n            \"git archive origin/main failed: {}\",\n            String::from_utf8_lossy(&archive.stderr).trim()\n        );\n    }\n    let mut child = Command::new(\"tar\")\n        .arg(\"-x\")\n        .arg(\"-C\")\n        .arg(&dest)\n        .stdin(Stdio::piped())\n        .stdout(Stdio::null())\n        .stderr(Stdio::piped())\n        .spawn()\n        .context(\"tar extract ops origin/main\")?;\n    if let Some(mut stdin) = child.stdin.take() {\n        use std::io::Write;\n        stdin.write_all(&archive.stdout)?;\n    }\n    let status = child.wait()?;","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/operate.rs#L875-L911","documentation":"materialize_ops_origin_main runs `git archive origin/main` into a buffer to materialize the ops (AUTO_MERGE / check script) tree from the remote-tracking main branch. This error wraps the git command's non-zero exit and surfaces git's own stderr.","triggerScenarios":"`git archive origin/main` exits non-zero — origin/main ref missing or stale, repository without that remote branch, corrupt objects, or git not able to read the ref.","commonSituations":"Fresh clone where origin/main has not been fetched; repo checked out without the origin remote; shallow clone lacking the ref; network-fetch failures leaving origin/main absent.","solutions":["Run `git fetch origin main` to create/update the origin/main ref","Verify `git rev-parse origin/main` resolves in the repo","Check remote configuration (`git remote -v`) and add/repair origin if missing","Inspect the wrapped stderr in the message for the underlying git cause"],"exampleFix":"// before (shell)\nmaterialize_ops_origin_main(...)  # assumes origin/main exists\n// after (shell)\ngit fetch origin main && materialize_ops_origin_main(...)","handlingStrategy":"try-catch","validationCode":"let has_ref = std::process::Command::new(\"git\").args([\"rev-parse\",\"--verify\",\"origin/main\"]).output().map(|o| o.status.success()).unwrap_or(false);","typeGuard":null,"tryCatchPattern":"match materialize_ops_origin_main(dest) { Err(e) if e.to_string().contains(\"git archive origin/main failed\") => { run_cmd(\"git fetch origin main\")?; retry_once(materialize_ops_origin_main, dest)?; } other => other?, }","preventionTips":["Run `git fetch origin main` before operate discovery","Verify `git rev-parse origin/main` in preflight","Keep origin remote configured in CI and containers"],"tags":["git","subprocess","archive"],"backgroundTag":"git-command-failed","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"}