{"record":{"id":"7167208ccbfd34f8","repo":"abhigyanpatwari/GitNexus","slug":"clone-head-is-not-an-immutable-commit","errorCode":null,"errorMessage":"clone HEAD is not an immutable commit","messagePattern":"clone HEAD is not an immutable commit","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"critical","filePath":"eval/workflow_bench/oracle_assets.py","lineNumber":272,"sourceCode":"    try:\n        root_metadata = root.lstat()\n        git_metadata = (root / \".git\").lstat()\n    except OSError as exc:\n        raise ValueError(f\"oracle sanitization requires a self-contained clone: {root}\") from exc\n    if (\n        stat.S_ISLNK(root_metadata.st_mode)\n        or not stat.S_ISDIR(root_metadata.st_mode)\n        or root.resolve(strict=True) != root\n        or stat.S_ISLNK(git_metadata.st_mode)\n        or not stat.S_ISDIR(git_metadata.st_mode)\n    ):\n        raise ValueError(f\"oracle sanitization requires a real self-contained clone: {root}\")\n\n    original_head = _git_checked(root, [\"rev-parse\", \"--verify\", \"HEAD^{commit}\"])\n    if len(original_head) not in {40, 64} or any(\n        character not in \"0123456789abcdefABCDEF\" for character in original_head\n    ):\n        raise ValueError(\"clone HEAD is not an immutable commit\")\n\n    hidden_tree_result = run_managed(\n        [\n            \"git\",\n            \"-C\",\n            str(root),\n            \"ls-tree\",\n            \"-d\",\n            \"--format=%(objectname)\",\n            \"HEAD\",\n            \"--\",\n            HIDDEN_HARNESS_PATH.as_posix(),\n        ],\n        timeout=60,\n        tail_bytes=1024,\n    )\n    if not hidden_tree_result.ok:\n        raise ValueError(\"cannot inspect the clone for committed benchmark harness data\")","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/oracle_assets.py#L254-L290","documentation":"Raised by sanitize_clone_for_hidden_oracles when `git rev-parse --verify HEAD^{commit}` does not return a string of exactly 40 or 64 hexadecimal characters (i.e. a SHA-1 or SHA-256 object id). Without a valid immutable commit at HEAD, the sanitizer cannot record the original HEAD for later update-ref and cannot guarantee a known starting point for history rewriting.","triggerScenarios":"The clone has no commits (unborn HEAD, fresh `git init` with nothing committed); HEAD is detached at a tag or non-commit object; git rev-parse output is malformed/empty; a corrupted repository where HEAD is not resolvable to a commit.","commonSituations":"Sanitizing a brand-new empty repo; a clone that failed to fetch any commits; a shallow clone with a broken HEAD; repository corruption; an unusual git version producing unexpected rev-parse output.","solutions":["Ensure the clone has at least one real commit on HEAD before sanitizing.","Re-clone from the source to get a valid HEAD commit.","Run `git -C <clone> rev-parse --verify HEAD^{commit}` manually and confirm it prints a 40- or 64-char hex SHA.","Check the clone is not shallow/corrupted with `git fsck`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import re\nfrom eval.workflow_bench.oracle_assets import _git_checked\n\ndef assert_head_commit(clone) -> None:\n    head = _git_checked(clone, [\"rev-parse\", \"--verify\", \"HEAD^{commit}\"])\n    if not re.fullmatch(r\"[0-9a-fA-F]{40}|[0-9a-fA-F]{64}\", head):\n        raise ValueError(f\"HEAD is not a valid commit SHA: {head!r}\")","typeGuard":"def head_is_immutable_commit(clone) -> bool:\n    import re\n    from eval.workflow_bench.oracle_assets import _git_checked\n    try:\n        head = _git_checked(clone, [\"rev-parse\", \"--verify\", \"HEAD^{commit}\"])\n    except Exception:\n        return False\n    return bool(re.fullmatch(r\"[0-9a-fA-F]{40}|[0-9a-fA-F]{64}\", head))","tryCatchPattern":"try:\n    head = sanitize_clone_for_hidden_oracles(clone)\nexcept ValueError as exc:\n    if \"not an immutable commit\" in str(exc):\n        raise SystemExit(\"Clone HEAD is unborn/invalid; commit at least once or re-clone\") from exc\n    raise","preventionTips":["Ensure the clone has at least one commit on the default branch.","Avoid sanitizing empty or freshly-init repos.","Re-clone from source if HEAD is in a bad state."],"tags":["python","benchmark","oracle","security","git","sanitization"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}