abhigyanpatwari/GitNexus · error · ValueError

unsafe Git metadata blocks oracle sanitization: {pseudo_ref}

Error message

unsafe Git metadata blocks oracle sanitization: {pseudo_ref}

What it means

The harness iterates pseudo-ref files under .git/ (AUTO_MERGE, MERGE_HEAD, ORIG_HEAD, REBASE_HEAD, FETCH_HEAD, shallow, etc.). Any that exists must be a regular non-symlink file or it is refused; a regular file is then unlinked. A symlink or directory pseudo-ref could redirect writes or escape .git, so the harness treats it as unsafe.

Source

Thrown at eval/workflow_bench/oracle_assets.py:401

    git_dir = root / ".git"
    for pseudo_ref in (
        "AUTO_MERGE",
        "BISECT_START",
        "CHERRY_PICK_HEAD",
        "FETCH_HEAD",
        "MERGE_HEAD",
        "ORIG_HEAD",
        "REBASE_HEAD",
        "REVERT_HEAD",
        "shallow",
    ):
        path = git_dir / pseudo_ref
        try:
            metadata = path.lstat()
        except FileNotFoundError:
            continue
        if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISREG(metadata.st_mode):
            raise ValueError(f"unsafe Git metadata blocks oracle sanitization: {pseudo_ref}")
        path.unlink()

    logs = git_dir / "logs"
    if logs.exists() or logs.is_symlink():
        logs_metadata = logs.lstat()
        if stat.S_ISLNK(logs_metadata.st_mode) or not stat.S_ISDIR(logs_metadata.st_mode):
            raise ValueError("unsafe Git reflog metadata blocks oracle sanitization")
        shutil.rmtree(logs)

    _git_checked(root, ["repack", "-A", "-d"], timeout=600)
    _git_checked(root, ["prune", "--expire=now"], timeout=600)
    _git_checked(root, ["prune-packed"], timeout=600)

    remaining_refs = _git_checked(root, ["for-each-ref", "--format=%(refname)"], timeout=60)
    if remaining_refs:
        raise ValueError("oracle sanitization left clone references recoverable")
    fsck = run_checked(
        ["git", "-C", str(root), "fsck", "--full", "--no-progress", "--no-reflogs", "--unreachable"],

View on GitHub (pinned to d540b00184)

Solutions

  1. Inspect `ls -la <clone>/.git/{MERGE_HEAD,ORIG_HEAD,REBASE_HEAD,FETCH_HEAD,shallow}` for symlinks/dirs.
  2. Abort any in-progress git operation: `git -C <clone> merge --abort`, `git -C <clone> rebase --abort`, etc., then delete the pseudo-ref file.
  3. Re-clone from a clean source if the pseudo-ref looks crafted.
Defensive patterns

Strategy: validation

Validate before calling

import stat
from pathlib import Path

_PSEUDO = ("AUTO_MERGE","BISECT_START","CHERRY_PICK_HEAD","FETCH_HEAD","MERGE_HEAD","ORIG_HEAD","REBASE_HEAD","REVERT_HEAD","shallow")
def pseudo_refs_are_regular(clone: Path) -> bool:
    for name in _PSEUDO:
        p = clone / ".git" / name
        try:
            st = p.lstat()
        except FileNotFoundError:
            continue
        if stat.S_ISLNK(st.st_mode) or not stat.S_ISREG(st.st_mode):
            return False
    return True

Type guard

def is_unsafe_pseudo_ref(exc: BaseException) -> bool:
    return isinstance(exc, ValueError) and "unsafe Git metadata blocks" in str(exc)

Try / catch

try:
    oracle_assets.sanitize_clone_for_hidden_oracles(clone)
except ValueError as exc:
    quarantine(clone)
    raise AbortTask(str(exc)) from exc

Prevention

When it happens

Trigger: Triggered when one of the enumerated .git pseudo-ref paths is a symbolic link or a directory rather than a regular file at sanitization time.

Common situations: A crafted clone that symlinks .git/MERGE_HEAD elsewhere; a leftover in-progress merge/rebase state from a reused clone; an aborted rebase that left REBASE_HEAD as a symlink on a broken FS.

Related errors


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