astrid-runtime/astrid · error

git could not read captured version

Error message

git could not read captured version: {}

What it means

For each valid revision, `version_chain_from_git` reads the file content with `git show <revision>:<path>`. If that subprocess fails, the error includes git's trimmed stderr, so this message reports why git could not read the captured version.

Solutions

  1. Read the included stderr in the error message — run the same `git show` command to reproduce.
  2. Fetch missing objects if in a partial/shallow clone (`git fetch --unshallow` or `--filter=blob:none` removal).
  3. Run `git fsck` to detect repository/object corruption.
  4. Ensure the repository is not mutated concurrently while the chain is being read.
Defensive patterns

Strategy: retry

Validate before calling

// Ensure the blob is locally available before reading
let out = Command::new("git").arg("-C").arg(&repo).args(["cat-file", "-e", &object]).output()?;
assert!(out.status.success(), "object {object} not present locally");

Try / catch

match version_chain_from_git(&repo, &path, name) {
    Err(e) if e.to_string().contains("could not read captured version") => {
        // parse stderr from the error; fetch missing objects, then retry once
    }
    other => other,
}

Prevention

When it happens

Trigger: `git show <rev>:<path>` returns non-zero — e.g. the path does not exist at that revision (though existence is pre-checked, races are possible), object corruption, or a shallow/partial clone lacking the blob.

Common situations: Partial/shallow clones where blobs were not fetched; corrupted or pruned objects; the file removed between the existence check and the show (TOCTOU in a live repo); permission issues running git in the repo.

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


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/d7d5727f2fcfdd7a. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-storage-chunker-evidence/src/corpus.rs:114

        }
        let revisions = String::from_utf8(revisions.stdout).context("git emitted non-UTF-8 IDs")?;
        let mut inputs = Vec::new();
        for revision in revisions.lines() {
            if revision.is_empty() || !revision.bytes().all(|byte| byte.is_ascii_hexdigit()) {
                bail!("git emitted an invalid revision ID");
            }
            if !git_path_exists_at_revision(repository, relative_path, revision)? {
                continue;
            }
            let object = format!("{revision}:{}", relative_path.to_string_lossy());
            let version = Command::new("git")
                .args(["-C"])
                .arg(repository)
                .args(["show", &object])
                .output()
                .context("read captured version")?;
            if !version.status.success() {
                bail!(
                    "git could not read captured version: {}",
                    String::from_utf8_lossy(&version.stderr).trim()
                );
            }
            inputs.push(memory(version.stdout));
        }
        if inputs.len() < 2 {
            bail!("captured version chain must contain at least two readable versions");
        }
        Self::from_files(name, CorpusKind::VersionChain, inputs)
    }

    pub fn synthetic_adversarial() -> Self {
        let mebibyte = 1024 * 1024;
        let inputs = vec![
            memory(Vec::new()),
            memory(vec![0x5a]),
            memory(vec![0x7e; 4093]),

View on GitHub (pinned to affd8760f4)