Repository navigation
Answer malformed walk and API requests with their documented 4xx - #78
Conversation
A negative Content-Length passed the size cap and read until the client hung up; it now counts as absent. A value that is present but unusable closes the connection, since the end of the body is unknown. Bodies nested too deeply to parse and coordinates too large for a float get a 400 instead of a dropped connection. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Self-review rubric (a self-review: no independent reviewer was involved):
Findings and gaps:
This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
|
Correction to the PR description and self-review:
The merge was made while This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
Content-Lengthis now treated as absent by_contentLength, sorfile.read(-1)is no longer reached and the size caps are enforced. 411 is returned byPOST /api/walksandPUT .../versions/<version>, and 400 is returned byPOST .../current.Content-Lengthis present but unusable (negative or non-numeric), because the end of the body is unknown. The close is set inside_contentLength, so the non-numeric case in_drainand_rollback, where the connection was previously left open, is covered too. The close already given to the negative case by_drainis preserved.RecursionErroris now caught in_leaveWalkand_rollback, and 400 is returned.walks._number, soRefusedis raised bycleanand 400 is returned.[Unreleased]section were updated.Closes #73
Test plan
python3 -m pytest -qon Python 3.8.10: 421 passed, 13 skippedserver.pyandwalks.pystashed, and all passed once they were restoredtest (3.8),test (3.12),docker. Thecheck-registrystep andblackcould not be run locally in this dispatch because both needed approval, socheck-registryis gated by CI andblackwas not runNotes for review
makeServerover a raw socket was tested.+5and1_000are still accepted byint(). These were left as they are, since a usable length is yielded and they were outside the scope of POST /api/walks can leave malformed requests unanswered #73._authoriseand the body of_drainwere not changed. The handling of a bad length in_drainis inherited from_contentLength.Issues not picked this cycle
src/arcade/bundle.py, a do-not-auto-merge path, must be changed by its fix. If it had been batched here, POST /api/walks can leave malformed requests unanswered #73 would have been held back from merging. Maintainer review is needed for it, and it remains the next candidate.This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
🤖 Generated with Claude Code