abhigyanpatwari/GitNexus · error · SandboxError

sanitized graph metadata is malformed

Error message

sanitized graph metadata is malformed

What it means

Reading or JSON-parsing .gitnexus/gitnexus.json raised OSError or json.JSONDecodeError. The metadata file the indexer should have written is missing, unreadable, or not valid JSON.

Source

Thrown at eval/workflow_bench/sanitized_graph.py:325

        ),
        timeout=GRAPH_QUERY_TIMEOUT_SECONDS,
        capture_stdout=True,
    )
    assert node_result is not None and relation_result is not None
    _parse_empty_query(node_result, label="sanitized graph node proof")
    _parse_empty_query(relation_result, label="sanitized graph relation proof")


def _validate_graph_metadata(root: Path, sanitized_head: str) -> None:
    for name in ("gitnexus.json", "meta.json", "lbug"):
        path = root / ".gitnexus" / name
        metadata = path.lstat()
        if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISREG(metadata.st_mode):
            raise SandboxError(f"sanitized graph asset must be regular and non-symlink: {path}")
    try:
        metadata_payload = json.loads((root / ".gitnexus" / "gitnexus.json").read_text())
    except (OSError, json.JSONDecodeError) as exc:
        raise SandboxError("sanitized graph metadata is malformed") from exc
    if metadata_payload.get("lastCommit") != sanitized_head:
        raise SandboxError("sanitized graph metadata is not bound to the parentless task commit")
    if not isinstance(metadata_payload.get("pdg"), dict) or not metadata_payload["pdg"]:
        raise SandboxError("sanitized graph metadata does not prove a --pdg build")


def prepare_sanitized_graph(
    task: Mapping[str, Any],
    *,
    repo: Path,
    resolved_sha: str,
    parent: Path,
    cache: TaskAssetCache,
    claude_bin: Path | str,
    bwrap_bin: Path | str,
    runtime_mounts: Sequence[ReadOnlyMount],
) -> SanitizedGraphSnapshot:
    """Sanitize, index offline once, scrub, and freeze graph assets for all arms."""

View on GitHub (pinned to d540b00184)

Solutions

  1. Open .gitnexus/gitnexus.json in the seed and inspect the parse error or partial content.
  2. Ensure _neutralize_target_index_inputs removed the prior .gitnexus (shutil.rmtree) before analyze.
  3. Confirm the analyze command actually completed (error 565) and the indexer version writes this metadata file.
  4. Rebuild the sanitized graph from a clean seed.
Defensive patterns

Strategy: try-catch

Validate before calling

import json, os

def assert_gitnexus_json_parses(root):
    p = os.path.join(root, ".gitnexus", "gitnexus.json")
    try:
        json.loads(open(p, "r", encoding="utf-8").read())
    except (OSError, json.JSONDecodeError) as exc:
        raise RuntimeError(f"gitnexus.json not parseable: {exc}") from exc

Try / catch

from workflow_bench.proposer_sandbox import SandboxError

try:
    prepare_sanitized_graph(...)
except SandboxError as exc:
    if "metadata is malformed" in str(exc):
        log.error("gitnexus.json unreadable/unparseable - confirm analyze completed and neutralization ran")
    raise

Prevention

When it happens

Trigger: The analyze run failed to write gitnexus.json (crashed mid-write), wrote a partial file, or a stale/foreign non-JSON file was left in place and survived _neutralize_target_index_inputs.

Common situations: Indexer crash during analyze (usually surfaced first as error 565); disk full mid-write; a leftover .gitnexus directory that neutralization should have removed.

Understand the failure class

Related errors


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