jdx/mise · error

failed to inspect Git blob

Error message

failed to inspect Git blob {oid}

What it means

`blob_starts_with` inspects a git blob (e.g. to check whether a config file starts with a comment/shebang) by piping content through a `git cat-file` child process. If the command exits non-zero before completing, the blob could not be read (bad object, corrupt repo, missing permissions) and mise raises this error with the offending oid.

Solutions

  1. Run `git cat-file -t <oid>` in the repo to confirm the object exists
  2. Fetch missing objects (`git fetch --unshallow` or `git fetch origin`) for shallow/partial clones
  3. Run `git fsck` to detect and repair a corrupt object store
  4. Re-clone the repository if the object store is damaged beyond repair

Example fix

// before: shallow clone lacks the blob
$ git clone --depth 1 <repo>
// after
$ git fetch --unshallow
Defensive patterns

Strategy: retry

Validate before calling

git cat-file -t <oid> || echo 'blob missing from object store'

Try / catch

match result {
    Err(e) if e.to_string().contains("failed to inspect Git blob") => {
        // re-fetch / unshallow, then retry once
    }
    Err(e) => return Err(e),
    Ok(v) => v,
}

Prevention

When it happens

Trigger: Calling code that checks a blob's prefix (`blob_starts_with`) against a repository where `git cat-file blob <oid>` fails: object missing (shallow/partial clone, pruned objects), corrupted object store, or a broken git installation.

Common situations: Reading mise-managed config from a shallow-cloned or partially-fetched repo; repo garbage-collected mid-operation; git in a broken state (dubious ownership, permission issues); passing an oid from a different repository.

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 jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/56dc11802e251441. Report an issue: GitHub.

Appendix: source

Thrown at src/git.rs:836

            .stderr(Stdio::inherit())
            .spawn()?;
        let mut bytes = Vec::new();
        // Keep the pipe open until Git has exited: dropping it before kill
        // can make a large blob emit a spurious broken-pipe error on stderr.
        let mut output = child
            .stdout
            .take()
            .expect("stdout was piped")
            .take(prefix.len() as u64);
        let read = output.read_to_end(&mut bytes);
        let complete = bytes.len() == prefix.len();
        if complete || read.is_err() {
            let _ = child.kill();
        }
        let status = child.wait()?;
        read?;
        if !complete && !status.success() {
            eyre::bail!("failed to inspect Git blob {oid}");
        }
        Ok(bytes == prefix)
    }

    /// Runs the call and returns its full output without treating a non-zero
    /// exit as an error, for commands whose status carries meaning.
    pub(crate) fn output_unchecked(&self, call: PlumbingCall<'_>) -> Result<std::process::Output> {
        let cmd = self.command(&call)?;
        spawn_plumbing(cmd, call.stdin)
    }

    /// Runs the call with stdout and stderr inherited, for output that goes
    /// straight to the terminal (a patch can be as large as a snapshot), and
    /// returns its status without treating a non-zero exit as an error.
    pub(crate) fn status_inherited(
        &self,
        call: PlumbingCall<'_>,
    ) -> Result<std::process::ExitStatus> {

View on GitHub (pinned to 533346cc37)