astrid-runtime/astrid · error
git emitted an invalid revision ID
Error message
git emitted an invalid revision ID
What it means
After enumerating revisions, `version_chain_from_git` sanity-checks each line: it must be non-empty and consist solely of ASCII hex digits (a valid object ID). Any malformed line from `git rev-list` triggers this error, protecting downstream `rev:path` object construction from garbage.
Source
Thrown at crates/astrid-storage-chunker-evidence/src/corpus.rs:101
repository: &Path,
relative_path: &Path,
) -> Result<Self> {
validate_relative_git_path(relative_path)?;
let revisions = Command::new("git")
.args(["-C"])
.arg(repository)
.args(["rev-list", "--reverse", "--max-count=32", "HEAD", "--"])
.arg(relative_path)
.output()
.context("enumerate captured version chain")?;
if !revisions.status.success() {
bail!("git could not enumerate the captured version chain");
}
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));View on GitHub (pinned to affd8760f4)
Solutions
- Inspect raw `git rev-list` stdout for extra non-ID lines (warnings, hook output).
- Disable git aliases/hooks/wrappers that emit extra output (e.g. run with clean config: `git -c core.hooksPath=/dev/null`).
- Ensure no pager/color config leaks into machine-readable output (set `GIT_PAGER=cat`, `--no-color`).
- Confirm the `git` binary on PATH is the real git, not a custom shim.
Defensive patterns
Strategy: validation
Validate before calling
fn is_valid_oid(s: &str) -> bool {
!s.is_empty() && s.bytes().all(|b| b.is_ascii_hexdigit())
}
// assert every line of `git rev-list` output passes is_valid_oid before use Try / catch
match version_chain_from_git(&repo, &path, name) {
Err(e) if e.to_string().contains("invalid revision ID") => {
// inspect raw rev-list output for injected lines (hooks, aliases, pagers)
}
other => other,
} Prevention
- Run git with a clean environment: disable hooks, aliases, pager and color for machine output
- Avoid wrapper scripts around git that print to stdout
- Pin the git binary/version used in CI corpus generation
When it happens
Trigger: A line of `git rev-list` stdout is empty or contains non-hex characters — e.g. warnings interleaved into stdout, hooks printing noise, or unexpected output format from a git wrapper/alias.
Common situations: Git wrappers/aliases or hooks injecting text into command output; locale/config (e.g. pager or color) settings altering output; a non-standard `git` shim on PATH.
Related errors
- Failed to clone repository from GitHub.
- empty byte specifier
- byte value must be non-negative and finite
- unknown byte suffix: {other}
- empty duration
AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09).
Data as JSON: /api/errors/282a8e73ea855744.
Report an issue: GitHub.