abhigyanpatwari/GitNexus · error · ValueError
unsafe Git reflog metadata blocks oracle sanitization
Error message
unsafe Git reflog metadata blocks oracle sanitization
What it means
Before `shutil.rmtree(.git/logs)`, the harness verifies .git/logs is a real directory and not a symlink. Calling rmtree on a symlinked logs would follow the link and delete arbitrary tree outside .git, so a symlink (or non-directory) logs is treated as unsafe.
Source
Thrown at eval/workflow_bench/oracle_assets.py:408
"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"],
timeout=600,
tail_bytes=MAX_CLONE_REF_BYTES,
)
if fsck.stdout_tail.strip() or fsck.stderr_tail.strip():
raise ValueError("oracle sanitization left unreachable Git objects recoverable")
forbidden_objects: list[tuple[str, str]] = []View on GitHub (pinned to d540b00184)
Solutions
- Inspect `ls -la <clone>/.git/logs`; if it is a symlink, remove the link: `rm <clone>/.git/logs`.
- If it is a regular file, delete it: `rm <clone>/.git/logs` (git will recreate a real directory when needed).
- Re-clone from a trusted source if the layout looks crafted.
Defensive patterns
Strategy: validation
Validate before calling
import stat
from pathlib import Path
def logs_is_real_dir_or_absent(clone: Path) -> bool:
logs = clone / ".git" / "logs"
try:
st = logs.lstat()
except FileNotFoundError:
return True
return not stat.S_ISLNK(st.st_mode) and stat.S_ISDIR(st.st_mode)
Type guard
def is_unsafe_reflog_metadata(exc: BaseException) -> bool:
return isinstance(exc, ValueError) and "unsafe Git reflog metadata" 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
- Never replace .git/logs with a symlink.
- Validate clone layout (e.g., via a tarball restore test) before reuse.
When it happens
Trigger: Triggered when .git/logs exists and lstat reports it as a symlink or non-directory (e.g., a regular file, or a symlink pointing outside the repo).
Common situations: A crafted clone that symlinks .git/logs to /tmp or another repo; a clone restored from a tarball that did not preserve directory-ness of .git/logs; a filesystem where logs was replaced by a file.
Related errors
- unsafe Git metadata blocks oracle sanitization: {pseudo_ref}
- oracle sanitization requires a real self-contained clone: {r
- benchmark harness checkout must contain only real directorie
- clone contains an unsafe reference name
- clone contains unsafe or unbounded remote metadata
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/22c32f6f98ddcd92.
Report an issue: GitHub.