{"record":{"id":"12b67f5ccb5c927e","repo":"astrid-runtime/astrid","slug":"git-could-not-inspect-captured-version","errorCode":null,"errorMessage":"git could not inspect captured version: {}","messagePattern":"git could not inspect captured version: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-chunker-evidence/src/corpus.rs","lineNumber":574,"sourceCode":"        bail!(\"git history path must be a relative in-repository path\");\n    }\n    Ok(())\n}\n\nfn git_path_exists_at_revision(\n    repository: &Path,\n    relative_path: &Path,\n    revision: &str,\n) -> Result<bool> {\n    let tree = Command::new(\"git\")\n        .args([\"-C\"])\n        .arg(repository)\n        .args([\"ls-tree\", \"--full-tree\", revision, \"--\"])\n        .arg(relative_path)\n        .output()\n        .context(\"inspect captured version path\")?;\n    if !tree.status.success() {\n        bail!(\n            \"git could not inspect captured version: {}\",\n            String::from_utf8_lossy(&tree.stderr).trim()\n        );\n    }\n    Ok(!tree.stdout.is_empty())\n}\n\nfn input_path(input: &Input) -> Option<&Path> {\n    match input {\n        Input::File { path, .. } => Some(path),\n        Input::Memory(_) => None,\n    }\n}\n\nfn memory(bytes: Vec<u8>) -> Input {\n    Input::Memory(Arc::from(bytes))\n}\n","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-chunker-evidence/src/corpus.rs#L556-L592","documentation":"`git_path_exists_at_revision` runs `git ls-tree --full-tree <revision> -- <path>` and bails with git's stderr when the command exits non-zero. Unlike a mere missing path (returns Ok(false)), this indicates git itself failed to inspect the captured version.","triggerScenarios":"`version_chain_from_git` querying a revision that doesn't exist or is malformed, running outside a valid repository (`REPO` path wrong), corrupt repo, or a git version lacking `--full-tree` support.","commonSituations":"Typo'd or abbreviated revision names in `--git-history`, repository path pointing at a worktree subdir instead of the repo root, HEAD on an unborn branch, or git hooks/env (GIT_DIR) interfering.","solutions":["Verify the revision exists: `git -C <repo> rev-parse --verify <revision>`","Confirm the REPO path is a valid git repository (`git -C <repo> status`) and inspect the stderr embedded in the message","Fix any conflicting GIT_DIR/GIT_WORK_TREE environment variables or upgrade git if `--full-tree` is unsupported"],"exampleFix":"// before\nlet chain = version_chain_from_git(&repo, \"main\", rel_path)?; // 'main' does not exist\n// after\nlet rev = \"a1b2c3d\"; // verified via git rev-parse --verify a1b2c3d\nlet chain = version_chain_from_git(&repo, rev, rel_path)?;","handlingStrategy":"retry","validationCode":"let ok = std::process::Command::new(\"git\").arg(\"-C\").arg(repo).args([\"rev-parse\", \"--verify\", rev]).status().map(|s| s.success()).unwrap_or(false);\nassert!(ok, \"revision {rev} not resolvable in {repo:?}\");","typeGuard":null,"tryCatchPattern":"match version_chain_from_git(repo, rev, rel) {\n    Ok(c) => c,\n    Err(e) if e.to_string().starts_with(\"git could not inspect captured version\") => {\n        eprintln!(\"git failed for {rev}; checking stderr, retrying once\");\n        verify_revision(repo, rev)?;\n        version_chain_from_git(repo, rev, rel)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Resolve short revision names to full SHAs with `git rev-parse` before use","Verify the REPO argument is the repository root, not a subdirectory","Unset GIT_DIR/GIT_WORK_TREE when spawning git from scripts"],"tags":["rust","git","cli","process"],"backgroundTag":"git-command-failed","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}