astrid-runtime/astrid · error
git could not inspect captured version: {}
Error message
git could not inspect captured version: {} What it means
`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.
Source
Thrown at crates/astrid-storage-chunker-evidence/src/corpus.rs:574
bail!("git history path must be a relative in-repository path");
}
Ok(())
}
fn git_path_exists_at_revision(
repository: &Path,
relative_path: &Path,
revision: &str,
) -> Result<bool> {
let tree = Command::new("git")
.args(["-C"])
.arg(repository)
.args(["ls-tree", "--full-tree", revision, "--"])
.arg(relative_path)
.output()
.context("inspect captured version path")?;
if !tree.status.success() {
bail!(
"git could not inspect captured version: {}",
String::from_utf8_lossy(&tree.stderr).trim()
);
}
Ok(!tree.stdout.is_empty())
}
fn input_path(input: &Input) -> Option<&Path> {
match input {
Input::File { path, .. } => Some(path),
Input::Memory(_) => None,
}
}
fn memory(bytes: Vec<u8>) -> Input {
Input::Memory(Arc::from(bytes))
}
View on GitHub (pinned to affd8760f4)
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
Example fix
// before let chain = version_chain_from_git(&repo, "main", rel_path)?; // 'main' does not exist // after let rev = "a1b2c3d"; // verified via git rev-parse --verify a1b2c3d let chain = version_chain_from_git(&repo, rev, rel_path)?;
Defensive patterns
Strategy: retry
Validate before calling
let ok = std::process::Command::new("git").arg("-C").arg(repo).args(["rev-parse", "--verify", rev]).status().map(|s| s.success()).unwrap_or(false);
assert!(ok, "revision {rev} not resolvable in {repo:?}"); Try / catch
match version_chain_from_git(repo, rev, rel) {
Ok(c) => c,
Err(e) if e.to_string().starts_with("git could not inspect captured version") => {
eprintln!("git failed for {rev}; checking stderr, retrying once");
verify_revision(repo, rev)?;
version_chain_from_git(repo, rev, rel)?
}
Err(e) => return Err(e),
} Prevention
- 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
When it happens
Trigger: `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.
Common situations: 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.
Understand the failure class
Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.
Related errors
- --git-history requires non-empty NAME=REPO::RELATIVE_PATH
- --git-history requires NAME=REPO::RELATIVE_PATH
- editor '{editor}' exited with non-zero status
- failed to fetch {name} from {url} (HTTP {})
- unexpected response shape: {other:?}
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/12b67f5ccb5c927e.
Report an issue: GitHub.