abhigyanpatwari/GitNexus · error · SandboxError

benchmark index metadata must be an object: {metadata_path}

Error message

benchmark index metadata must be an object: {metadata_path}

What it means

Raised by isolated_gitnexus_registry_mount after JSON parsing succeeds but the top-level value is not a JSON object (dict). The registry entry is built by reading fields like indexedAt and lastCommit off the metadata, so a non-object (array, string, number, null, bool) is unusable and rejected. This is a structural validation of the index descriptor.

Source

Thrown at eval/workflow_bench/runner.py:350

    return tuple(worktree / ".claude" / "skills" / name for name in EVALUATED_ARM_SKILLS.get(arm, ()))


def isolated_gitnexus_registry_mount(worktree: Path, parent: Path) -> ReadOnlyMount:
    """Create a one-clone registry that cannot route MCP to any host repo."""

    metadata_path = worktree / ".gitnexus" / "gitnexus.json"
    if not metadata_path.exists():
        metadata_path = worktree / ".gitnexus" / "meta.json"
    mode = metadata_path.lstat().st_mode
    if stat.S_ISLNK(mode) or not stat.S_ISREG(mode):
        raise SandboxError(f"benchmark index metadata must be regular and non-symlink: {metadata_path}")
    raw = _bounded_regular_bytes(metadata_path, limit=2 * 1024 * 1024)
    try:
        metadata = json.loads(raw)
    except json.JSONDecodeError as exc:
        raise SandboxError(f"benchmark index metadata is malformed: {metadata_path}") from exc
    if not isinstance(metadata, dict):
        raise SandboxError(f"benchmark index metadata must be an object: {metadata_path}")
    indexed_at = metadata.get("indexedAt")
    last_commit = metadata.get("lastCommit")
    if not isinstance(indexed_at, str) or not indexed_at or not isinstance(last_commit, str) or not last_commit:
        raise SandboxError("benchmark index metadata is missing indexedAt or lastCommit")

    parent = parent.expanduser().absolute()
    registry = Path(tempfile.mkdtemp(prefix="wfbench-registry-", dir=parent))
    registry.chmod(0o700)
    entry: dict[str, Any] = {
        "name": "benchmark-target",
        "path": SANDBOX_WORKSPACE,
        "storagePath": f"{SANDBOX_WORKSPACE}/.gitnexus",
        "indexedAt": indexed_at,
        "lastCommit": last_commit,
    }
    for field in ("remoteUrl", "stats", "branch"):
        if field in metadata:
            entry[field] = metadata[field]

View on GitHub (pinned to d540b00184)

Solutions

  1. Inspect the top-level JSON type: `python3 -c "import json; print(type(json.load(open('<worktree>/.gitnexus/gitnexus.json'))))"` — it must be dict.
  2. If it is an array or scalar, regenerate the index with the matching indexer version so an object is written.
  3. Make sure gitnexus.json/meta.json is the index descriptor, not the registry.json list the harness itself writes.
  4. Re-run `node .gitnexus/run.cjs analyze --index-only` to produce a well-formed object descriptor.

Example fix

// before — top-level is an array (wrong file/format)
[ {"indexedAt": "...", "lastCommit": "..."} ]
// after — regenerate an object descriptor
rm <worktree>/.gitnexus/gitnexus.json
node .gitnexus/run.cjs analyze --index-only
Defensive patterns

Strategy: type-guard

Validate before calling

import json
from pathlib import Path

d = json.loads((worktree / '.gitnexus' / 'gitnexus.json').read_bytes())
assert isinstance(d, dict), f'top-level metadata must be an object, got {type(d).__name__}'

Type guard

import json
from typing import Any

def is_metadata_object(raw: bytes) -> bool:
    try:
        v = json.loads(raw)
    except json.JSONDecodeError:
        return False
    return isinstance(v, dict)

Try / catch

from .proposer_sandbox import SandboxError

try:
    mount = isolated_gitnexus_registry_mount(worktree, parent)
except SandboxError as exc:
    if 'must be an object' in str(exc):
        # regenerate the index so a proper object descriptor is written
        raise
    raise

Prevention

When it happens

Trigger: json.loads(raw) returned a list, string, number, bool, or None (not a dict), so `isinstance(metadata, dict)` is False.

Common situations: The indexer (or a hand edit) wrote a top-level JSON array or a bare value; an older/newer indexer format changed the top-level shape; the wrong file was placed at .gitnexus/gitnexus.json (e.g. a registry array meant for registry.json).

Related errors


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