Repository navigation
Conversation
stored() and revalidating() both build their reply from a GET regardless of the caller's own method: stored() always does env.ASSETS.fetch(new URL(request.url)), a GET by construction, and revalidating() serves the shared copy, which is always a GET's. Neither checked the original request's method before returning it. This is the other half of the concern test_a_head_request_can_never_become_the_ stored_body already covers -- that test protects the shared cache from a HEAD's empty body landing in it; this protects the HEAD caller itself from receiving a GET's full body back, which HTTP forbids a HEAD reply from carrying. Most concretely: HEAD /rooms, the one EDGE_REVALIDATE_SECONDS path today, would answer with the full room listing on every HEAD instead of an empty body. Fixed at the single dispatch point in the exported fetch handler, after route() decides what to serve, rather than patching stored()/revalidating() separately -- applies uniformly to every lane (static-first, edge-only, revalidating) with one change instead of three. New regression test verified to fail against the unfixed code (confirmed by reverting the fix locally and re-running) and pass with it restored. 665 tests pass, lint/format/ty/sz all green. No CHANGELOG.md edit -- maintainer- regenerated per CONTRIBUTING.md; proposed wording is in the PR body.
|
Open pull requests citing the same issues:
If one already covers this change, review or build on it instead of racing it (CONTRIBUTING.md "Overlapping work"). |
luch91
left a comment
There was a problem hiding this comment.
Reviewed exact head 41d223b0beb5e976563d2fa4883ab11da41706. The top-level Worker handler strips the body after
oute() resolves, so the rule applies uniformly to static-first, edge-only, and revalidating lanes while preserving status and headers. It complements the existing cache-protection test, which prevents a HEAD request from populating a shared GET cache with an empty body. The regression checks the central ordering and null-body construction; the PR reports full tests, Ruff, format, type, and size checks passing, and queue-guard checks are green. No blocker found.
|
Correction to my review text: the exact verified head SHA is 41d223b. The approval was submitted against that head; only the SHA transcription in the review body was mistyped. |
luch91
left a comment
There was a problem hiding this comment.
Reviewed exact head 41d223b0beb5e9767515632da4883ab11da41706. The Worker now applies one central HEAD-body strip after route() returns, so cached/static/revalidating lanes cannot return a GET body to a HEAD caller while still preserving status and headers. The test verifies the check is after route dispatch and constructs a null-body response, covering the cross-lane invariant rather than one branch. Protected-files and overlap checks are green. Approved.
|
@sv Checking in on this one too -- approved by luch91 a couple weeks ago, no movement since. Let me know if it needs a rebase against current main. |
|
Correct and central: One check: for a 304/204, constructing a new Response with a body-less status is fine; for a HEAD to a streamed response, ensure the original body is cancelled ( |
What
stored()andrevalidating()inedge/src/worker.jsboth build their reply from a GET regardless of the caller's own method:stored()always doesenv.ASSETS.fetch(new URL(request.url)), a GET by construction;revalidating()serves the shared copy, which is always a GET's. Neither checked the original request's method before returning a body-bearingResponse.Why this is the other half of an already-covered concern
test_a_head_request_can_never_become_the_stored_bodyalready protects the shared cache from a HEAD's empty body landing in it and corrupting what later GET readers see. This fixes the adjacent, previously-uncovered direction: a HEAD caller receiving a GET's full body back, which HTTP forbids a HEAD reply from carrying at all.Most concretely:
HEAD /rooms— the oneEDGE_REVALIDATE_SECONDSpath today (added in #674) — would answer with the complete room listing on every HEAD instead of an empty body. The same gap exists for anything inSTATIC_FIRSTorEDGE_ONLYtoo, since both go throughstored().Fix
One check, at the single dispatch point in the exported
fetchhandler, afterroute()decides what to serve — rather than patchingstored()/revalidating()separately in three places:Applies uniformly to every lane with one change.
Testing
test_a_head_reply_never_carries_a_body, following the existing source-text-assertion pattern this file already uses (no JS harness available, per_between's own docstring)uv run pytest tests -q: 665 passeduv run ruff check ./uv run ruff format --check ./uv run ty check: cleanpython3 sz.py --check: unaffected —edge/isn't in the core budgetRelease note
Since CHANGELOG.md is maintainer-regenerated, proposed wording for [Unreleased]:
PATCH: a HEAD request to any edge-served document path (static-first, edge-only, or the revalidating /rooms lane) no longer receives the GET's full body back — the top-level fetch handler now strips it to null, matching HTTP's requirement that a HEAD reply carry no body.
Abuse impact
None. Pure correctness fix to an existing lane; no new route, parameter, or persistent state.