abhigyanpatwari/GitNexus · error · RuntimeError

sandboxed git diff did not produce a SHA-256 digest

Error message

sandboxed git diff did not produce a SHA-256 digest

What it means

Thrown by implementation_diff_digest when the diff|sha256sum pipeline reported success (exit 0) but the captured stdout does not start with a 64-char lowercase hex SHA-256 digest. The harness trusts only a well-formed digest as the implementation fingerprint, so a malformed/empty result is rejected even though the command nominally succeeded.

Source

Thrown at eval/workflow_bench/runner_artifacts.py:400

    if not re.fullmatch(r"[0-9a-fA-F]{40,64}", orig_sha):
        raise ValueError(f"unsafe git object id: {orig_sha!r}")
    if prepare_untracked:
        _prepare_untracked_for_diff(sandbox)
    command = (
        "/usr/bin/git -c core.fsmonitor=false diff --no-ext-diff --no-textconv --binary "
        f"{orig_sha} -- . ':(exclude)docs/plans' ':(exclude).claude/skills' "
        "| /usr/bin/sha256sum"
    )
    result = sandbox.run(
        ["/bin/sh", "-c", command],
        timeout=60,
        env=build_sandbox_environment(),
    )
    if not result.ok:
        raise ManagedProcessError(command, result)
    digest = result.stdout_tail.strip().split()[0] if result.stdout_tail.strip() else ""
    if not re.fullmatch(r"[0-9a-f]{64}", digest):
        raise RuntimeError("sandboxed git diff did not produce a SHA-256 digest")
    return digest


def diff_churn(
    sandbox: SandboxSession,
    orig_sha: str,
    *,
    prepare_untracked: bool = True,
) -> dict[str, int]:
    """Return code churn versus the arm's starting SHA."""

    if prepare_untracked:
        _prepare_untracked_for_diff(sandbox)
    output = _sandbox_git(
        sandbox,
        [
            "diff",
            "--no-ext-diff",

View on GitHub (pinned to d540b00184)

Solutions

  1. Check that the sandbox run captured stdout (not just stderr) — implementation_diff_digest reads result.stdout_tail.
  2. Confirm the diff actually completed; a 0-exit with empty stdout suggests the pipeline was short-circuited or the buffer rolled over.
  3. If the diff is enormous, the streamed stdout may exceed the tail buffer; reduce the diff scope or increase capture (harness-level change).
  4. Ensure orig_sha matches a real commit so `git diff orig_sha` emits a real diff rather than an error swallowed by the pipe.

Example fix

// before — relying on a possibly-truncated tail
digest = result.stdout_tail.strip().split()[0]

// after — verify the pipeline wrote exactly one digest line
assert result.stdout_tail.strip().count('\n') == 0
digest = result.stdout_tail.strip()
assert re.fullmatch(r'[0-9a-f]{64}', digest)
Defensive patterns

Strategy: validation

Validate before calling

import re

def is_sha256_digest(s: str) -> bool:
    return isinstance(s, str) and bool(re.fullmatch(r'[0-9a-f]{64}', s))

Type guard

import re

def is_sha256_digest(s: str) -> bool:
    return isinstance(s, str) and bool(re.fullmatch(r'[0-9a-f]{64}', s))

Try / catch

try:
    digest = implementation_diff_digest(sandbox, orig_sha)
except RuntimeError as e:
    if 'did not produce a SHA-256 digest' in str(e):
        # check stdout capture, confirm git diff actually emitted output
        raise
    raise

Prevention

When it happens

Trigger: After result.stdout_tail.strip().split()[0], the token does not fullmatch [0-9a-f]{64}. Causes: empty stdout (diff produced nothing and sha256sum of empty stdin still prints a digest, so this implies truncation/capture loss), stdout buffer overflowed so only a fragment remained, or the pipeline emitted a warning line before the digest.

Common situations: The sandbox stdout tail buffer truncated the digest line; sha256sum printed to stderr only; a non-English locale prefixed output; the harness's stdout capture window was exceeded by a huge diff (though --binary diff piped to sha256sum should stay small).

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/459c1b2a77d8db8f. Report an issue: GitHub.