{"record":{"id":"c3451cd1e3660b80","repo":"abhigyanpatwari/GitNexus","slug":"benchmark-index-metadata-is-malformed-metadata-p","errorCode":null,"errorMessage":"benchmark index metadata is malformed: {metadata_path}","messagePattern":"benchmark index metadata is malformed: (.+?)","errorType":"exception","errorClass":"SandboxError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/runner.py","lineNumber":348,"sourceCode":"    \"\"\"Repo-local prompt roots that must remain immutable during a session.\"\"\"\n\n    return tuple(worktree / \".claude\" / \"skills\" / name for name in EVALUATED_ARM_SKILLS.get(arm, ()))\n\n\ndef isolated_gitnexus_registry_mount(worktree: Path, parent: Path) -> ReadOnlyMount:\n    \"\"\"Create a one-clone registry that cannot route MCP to any host repo.\"\"\"\n\n    metadata_path = worktree / \".gitnexus\" / \"gitnexus.json\"\n    if not metadata_path.exists():\n        metadata_path = worktree / \".gitnexus\" / \"meta.json\"\n    mode = metadata_path.lstat().st_mode\n    if stat.S_ISLNK(mode) or not stat.S_ISREG(mode):\n        raise SandboxError(f\"benchmark index metadata must be regular and non-symlink: {metadata_path}\")\n    raw = _bounded_regular_bytes(metadata_path, limit=2 * 1024 * 1024)\n    try:\n        metadata = json.loads(raw)\n    except json.JSONDecodeError as exc:\n        raise SandboxError(f\"benchmark index metadata is malformed: {metadata_path}\") from exc\n    if not isinstance(metadata, dict):\n        raise SandboxError(f\"benchmark index metadata must be an object: {metadata_path}\")\n    indexed_at = metadata.get(\"indexedAt\")\n    last_commit = metadata.get(\"lastCommit\")\n    if not isinstance(indexed_at, str) or not indexed_at or not isinstance(last_commit, str) or not last_commit:\n        raise SandboxError(\"benchmark index metadata is missing indexedAt or lastCommit\")\n\n    parent = parent.expanduser().absolute()\n    registry = Path(tempfile.mkdtemp(prefix=\"wfbench-registry-\", dir=parent))\n    registry.chmod(0o700)\n    entry: dict[str, Any] = {\n        \"name\": \"benchmark-target\",\n        \"path\": SANDBOX_WORKSPACE,\n        \"storagePath\": f\"{SANDBOX_WORKSPACE}/.gitnexus\",\n        \"indexedAt\": indexed_at,\n        \"lastCommit\": last_commit,\n    }\n    for field in (\"remoteUrl\", \"stats\", \"branch\"):","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/runner.py#L330-L366","documentation":"Raised by isolated_gitnexus_registry_mount when the (already-validated regular, non-symlink) metadata file cannot be parsed as JSON. The bytes are read via _bounded_regular_bytes (2 MiB cap) and json.loads is attempted; a JSONDecodeError is wrapped as a SandboxError pointing at the metadata path. This guards the registry mount against a corrupt or truncated index descriptor.","triggerScenarios":"metadata_path passed _bounded_regular_bytes but json.loads(raw) raised json.JSONDecodeError — the file exists and is regular but its contents are not valid JSON (truncated, hand-edited, or written by a crashing indexer).","commonSituations":"A previous indexing run was killed mid-write leaving a truncated .gitnexus/gitnexus.json; the file was hand-edited and broke syntax; a different/older indexer wrote a non-JSON format; encoding issues (BOM, mixed encoding) make json.loads fail.","solutions":["Validate the file directly: `python3 -c \"import json,sys; json.load(open('<worktree>/.gitnexus/gitnexus.json'))\"` and read the parse error.","If corrupt/truncated, delete it and regenerate: `node .gitnexus/run.cjs analyze --index-only`.","Confirm the indexer completed successfully (exit 0) before running the harness.","If hand-edited, reformat as strict JSON and re-validate."],"exampleFix":"// before — truncated/corrupt JSON in the index metadata file\n{ \"indexedAt\": \"2026-07-12T00:00:00Z\", \"lastCommit\": \"ab\n// after — regenerate a complete, valid descriptor\nrm <worktree>/.gitnexus/gitnexus.json\nnode .gitnexus/run.cjs analyze --index-only","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\ndef metadata_parses(path: Path) -> bool:\n    try:\n        json.loads(path.read_bytes())\n        return True\n    except json.JSONDecodeError:\n        return False\n\nassert metadata_parses(mp), f'{mp} is not valid JSON'","typeGuard":null,"tryCatchPattern":"from .proposer_sandbox import SandboxError\n\ntry:\n    mount = isolated_gitnexus_registry_mount(worktree, parent)\nexcept SandboxError as exc:\n    if 'malformed' in str(exc):\n        # corrupt/truncated JSON; regenerate the index\n        raise\n    raise","preventionTips":["Confirm the indexer exited 0 before running the harness.","Validate index JSON parses after every indexing step in CI.","Never hand-edit .gitnexus/gitnexus.json."],"tags":["sandbox","registry","gitnexus","json","validation"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}