fix: name the archive and member when an Inspect .eval log has a malformed header.json or sample
When a member of an Inspect .eval archive is malformed, evalarc diff now names the archive and the member in its error. Before this change it printed a bare Python error. If header.json or a samples/*.json member is not valid UTF-8 JSON, stderr reads "evalarc: <archive> member '<name>' is not valid JSON: <decoder message>." The message then gives the recovery step: re-export with inspect log dump LOG.eval > LOG.json, or rerun the evaluation. If header.json parses to an array, string, number or null, stderr reads "evalarc: <archive> member 'header.json' must be a JSON object (got <type>): ..." followed by the same recovery advice. Member names go through the existing _shown_id helper. It quotes the name, escapes control characters and cuts long names at 80 characters. The command still exits 2, writes nothing to stdout and creates no --output folder. With --markdown, a missing Markdown file is not created and an existing one keeps its bytes. Valid archives load as before. docs/ci-gate.md and docs/ci-gate.zh-CN.md describe the new messages. The controller ran every check on commit b5714bfebc29382934031c7f4c9795a06db3a117. I ran nothing and wrote this text from the controller's receipts and the review findings. Before the fix, the controller ran tests/test_feature_1e31601a8900.py: 15 failed and 2 passed. The failures recorded the old stderr text, for example 'evalarc: Expecting value: line 1 column 1 (char 0)', 'evalarc: list indices must be integers or slices, not str', "'str' / 'int' / 'NoneType' object does not support item assignment" and a bare 'utf-8' codec decode error. None of them named the archive or the member. After the fix, the controller ran that test file, the full pytest suite, ruff check, ruff format --check, python scripts/build_site.py and node scripts/check_site.cjs. All six exited 0.
Use it
Prerequisites: evalarc installed, Python 3, and a checkout of this repository for the bundled baseline. Run the commands from the repository root. The archives below are synthetic and built by hand. They are not real Inspect exports.
# 1. Synthetic archive whose header.json is not JSON
python - <<'PY'
import zipfile
with zipfile.ZipFile("current.eval", "w") as z:
z.writestr("header.json", "not json")
PY
# 2. Gate it against the bundled JSON baseline
evalarc diff examples/results-diff/inspect/baseline.json current.eval --output review/ --markdown summary.md
echo "exit=$?"
Expected: stderr starts with "evalarc: current.eval member 'header.json' is not valid JSON: Expecting value: line 1 column 1 (char 0)." and then gives the recovery step. The script prints exit=2. Neither review/ nor summary.md is created.
# 3. Synthetic archive whose header.json is not an object
python - <<'PY'
import zipfile
with zipfile.ZipFile("array.eval", "w") as z:
z.writestr("header.json", "[]")
PY
evalarc diff examples/results-diff/inspect/baseline.json array.eval --output review/
echo "exit=$?"
Expected: stderr contains "evalarc: array.eval member 'header.json' must be a JSON object (got array)". The script prints exit=2. To match the message in CI, grep for "must be a JSON object (got array)".
Recovery for a real log: run inspect log dump current.eval > current.json, then diff the JSON log, or rerun the evaluation.
Tests: python -m pytest -q tests/test_feature_1e31601a8900.pyScope
Scope: only the error text on the Inspect .eval path changed. It covers invalid-JSON and invalid-UTF-8 members and a non-object header.json. The change adds no format, option, recovery or partial loading. One bad member still rejects the whole input. Error text for JSON logs, promptfoo and JUnit is unchanged. The archive file name is still printed unescaped, as in the existing archive errors. Evidence: every test archive is synthetic. The tests do not show which corruptions real Inspect exports produce, and this change does not fix upstream Inspect issue #5434. Passing tests show that the tested inputs produce the tested messages and that --output and --markdown files stay untouched for those inputs. They do not show coverage of every possible archive defect. Browser evidence: the controller ran node scripts/check_site.cjs and it passed. Its log shows the site's existing showcase checks at widths 1440, 390 and 320 (keyboard, links, downloads, offline modes). Those are regression checks for other site pages, not a review of this change. This change has no UI, and nobody reviewed screenshots of it.
Upgrade and rollback
No schema, CLI flag or output file changed. Inputs that loaded before load the same way, and inputs that exited 2 still exit 2. The only new behavior is the stderr text for malformed .eval archives. CI scripts that match the old decoder or TypeError text need updating, for example 'list indices must be integers or slices, not str' or a bare 'Expecting value' line. No documented contract promised that text. To roll back, revert commit b5714bfebc29382934031c7f4c9795a06db3a117. No data migration is needed.