Skip to content

🐛 fix(query): reject malformed candidates - #231

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:bug/reject-wrong-shape-json
Nov 3, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:bug/reject-wrong-shape-json

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

The subprocess probe accepted exit-zero JSON without confirming it came from the interpreter collector. Empty objects raised during deserialization, and partial objects raised during interpreter resolution, stopping discovery before it tried the next PATH candidate. The probe now rejects responses without the collector's markers or required interpreter fields. Fixes #197.

The response lacked the collector's markers

The collector wraps its JSON in two query markers. The old probe parsed output even when the markers were absent. The probe now rejects that output, so a program that ignores the collector script cannot supply a result by printing JSON.

Deserialization accepted incomplete objects

The old from_dict() restored version_info and copied the remaining keys without checking whether the collector's required fields existed. It now rejects missing fields. The probe treats malformed results as failed queries, and the cache discards incomplete entries.

Behavior changes

Discovery retries a failed query and continues to later candidates on PATH when a candidate omits query markers or required metadata. Direct PythonInfo.from_dict() and from_json() calls raise ValueError for objects missing required fields. A candidate that reproduces both markers and all required fields can still supply false values; the query protocol does not authenticate subprocess output.

Reported by Anthropic's OSS Scanner: ANT-2026-T9IA1FTF.

@gaborbernat gaborbernat added the bug Something isn't working label Nov 3, 2026
A named executable can print JSON without running the collector, and a
partial payload can deserialize into a PythonInfo missing required fields.
Reject missing query markers and incomplete data so discovery tries the next
candidate.

Fixes tox-dev#197
@gaborbernat
gaborbernat force-pushed the bug/reject-wrong-shape-json branch from 5fdf325 to 75e541f Compare November 3, 2026 04:57
@gaborbernat
gaborbernat merged commit e3f2e93 into tox-dev:main Nov 3, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong-shape JSON from a candidate aborts discovery

1 participant