abhigyanpatwari/GitNexus · error · SandboxError

{label} did not return strict JSON

Error message

{label} did not return strict JSON

What it means

In _parse_empty_query, decoding the captured stdout as strict UTF-8 or json.loads-parsing it failed. The cypher marker-proof result must be strict JSON (either [] or an object with row_count) for the harness to trust the empty-set verdict.

Source

Thrown at eval/workflow_bench/sanitized_graph.py:281

    if not result.ok:
        raise ManagedProcessError(command, result)
    if not capture_stdout:
        return None
    if result.stdout_capture is None or result.stdout_capture_overflow:
        raise SandboxError("bounded graph-query output was unavailable")
    return result.stdout_capture


def _marker_predicate(variable: str) -> str:
    literals = ("'" + marker.replace("\\", "\\\\").replace("'", "\\'") + "'" for marker in GRAPH_MARKERS)
    return " OR ".join(f"CAST({variable} AS STRING) CONTAINS {literal}" for literal in literals)


def _parse_empty_query(raw: bytes, *, label: str) -> None:
    try:
        payload = json.loads(raw.decode("utf-8", errors="strict"))
    except (UnicodeError, json.JSONDecodeError) as exc:
        raise SandboxError(f"{label} did not return strict JSON") from exc
    if payload == []:
        return
    if isinstance(payload, dict) and payload.get("row_count") == 0:
        return
    raise SandboxError(f"{label} found recoverable benchmark harness references")


def _scrub_and_verify_graph(prefix: Sequence[str]) -> None:
    node_predicate = _marker_predicate("n")
    relation_predicate = _marker_predicate("r")
    node_result = _run_graph_cli(
        prefix,
        ("cypher", f"MATCH (n) WHERE {node_predicate} RETURN n LIMIT 1", "-r", "benchmark-target", "--limit", "1"),
        timeout=GRAPH_QUERY_TIMEOUT_SECONDS,
        capture_stdout=True,
    )
    relation_result = _run_graph_cli(
        prefix,

View on GitHub (pinned to d540b00184)

Solutions

  1. Dump the raw captured bytes to inspect what the CLI actually emitted.
  2. Confirm the gitnexus CLI version produces JSON for the cypher subcommand with the given flags.
  3. Set LANG/LC_ALL appropriately in _graph_environment() so the CLI emits UTF-8.
  4. Ensure the cypher subcommand writes JSON to stdout and diagnostics to stderr.
Defensive patterns

Strategy: try-catch

Validate before calling

import json

def assert_cypher_json(raw: bytes):
    try:
        json.loads(raw.decode("utf-8", errors="strict"))
    except (UnicodeError, json.JSONDecodeError) as exc:
        raise RuntimeError(f"cypher output not strict JSON: {exc}; head={raw[:200]!r}") from exc

Try / catch

from workflow_bench.proposer_sandbox import SandboxError

try:
    prepare_sanitized_graph(...)
except SandboxError as exc:
    if "did not return strict JSON" in str(exc):
        log.error("cypher proof emitted non-JSON - check CLI version and locale in _graph_environment()")
    raise

Prevention

When it happens

Trigger: The 'gitnexus cypher ... -r benchmark-target' query returned non-JSON (human-readable text, an error banner, partial output) or non-UTF-8 bytes despite exiting 0.

Common situations: A CLI version change altering cypher output formatting; an error message printed to stdout instead of stderr with exit 0; locale/encoding issues inside the sandbox producing non-UTF-8 text.

Related errors


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