Skip to content

fix(backend): contain response serialization failures - #322

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
AryanRG:codex/fix-backend-response-serialization
Oct 17, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
AryanRG:codex/fix-backend-response-serialization

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

When a build hook returns a non-JSON value such as a Path, bytes or a set, the runner currently writes a partial response file. The frontend then raises JSONDecodeError instead of reporting the backend failure.

Serialize the response before opening the result file, and handle serialization errors through the existing backend exception envelope. Replace the success dictionary when reporting an error so it cannot retain a return key. If formatting or serializing the exception also fails, emit a fixed JSON-safe error response. Reset the serialized response for each request so a reused process cannot return an earlier success after a malformed SystemExit code.

Add seven regression cases covering invalid hook returns and invalid exit codes, both on the first request and after a successful request, with subsequent recovery and clean shutdown. These hooks test response transport and lifecycle; their synthetic wheel names do not establish wheel production.

This addresses malformed backend results and exceptions. It does not establish a failure with a conforming backend or a production incident, and it does not make response-file writes atomic or cover file I/O failures and resource exhaustion.

Validation on macOS arm64:

  • Publication reruns: seven focused cases passed; the full CPython 3.15 free-threaded suite passed all 96 tests with 100% line/branch coverage of runtime and tests; 70 supplemental adversarial/reuse cases passed on CPython 3.15.
  • Configured tox run -e fix,type,docs,pkg_meta passed, including all pre-commit hooks, typing, strict Sphinx build, sdist/wheel build, twine and wheel-content checks.
  • Earlier validation ran the 96-test full suite on CPython 3.11–3.15 and 3.15 free-threaded. The updated frontend construction example also built a real wheel on each interpreter.

Linux, Windows and hosted CI have not been verified for this patch locally. AI assistance was used to prepare implementation and regression tests.

Serialize current-request responses before writing them and preserve error reporting and recovery for malformed hook results and exceptions.

Developed, tested and reviewed with AI assistance. No independent human review is claimed.
@gaborbernat
gaborbernat enabled auto-merge (squash) October 17, 2026 10:31
@gaborbernat
gaborbernat merged commit 368e3a8 into tox-dev:main Oct 17, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants