Repository navigation
fix(gateway): apply conditional requests consistently to media - #116880
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 10:45 AM ET / 14:45 UTC. ClawSweeper reviewWhat this changesThe PR makes Gateway assistant and managed media return Merge readinessKeep this PR open for explicit maintainer review. The supplied diff and PR evidence describe a focused HTTP-cache correctness fix with real Gateway behavior proof, but the Priority: P2 Review scores
Verification
How this fits togetherGateway HTTP handlers authenticate requests for Control UI assistant media and managed outgoing attachments, then decide whether to send a full file, a byte range, or a cache revalidation response. This change centralizes the conditional-request decision before those handlers open or stream the representation body. flowchart LR
Client[Control UI client] --> Request[Authenticated media request]
Request --> Conditional[Conditional validator check]
Conditional --> Range[Byte-range response planning]
Range --> Assistant[Assistant media handler]
Range --> Managed[Managed attachment handler]
Assistant --> Response[HTTP media response]
Managed --> Response
Decision needed
Why: The patch changes shared cache-validation behavior across authenticated media endpoints, and local source/history inspection was unavailable to independently confirm all owners and upgrade implications. Before merge
Agent review detailsSecurityNone. PR surfaceSource +31, Tests +143. Total +174 across 9 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase onto current Do we have a high-confidence way to reproduce the issue? Unclear for an independent local run: the PR supplies a concrete authenticated GET/HEAD reproduction and targeted regression tests, but the review sandbox prevented executing or reading the current-main path directly. Is this the best way to solve the issue? Unclear: centralizing the validator appears to avoid three diverging implementations, but the best-fix judgment needs a current-main caller, sibling, and history review after the branch is rebased. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e93de3608161. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
Co-authored-by: Peter Steinberger <[email protected]>
Summary
If-None-Matchvalidators for bothGETandHEADbefore consideringRangeorIf-Range.304 Not ModifiedwithoutContent-Length, close the existing verified file descriptor, and preserve stale-validator206ranges, authentication, path ownership, playback behavior, and cache policy.Root cause
src/gateway/http-byte-range.tsgenerated and advertised strong media ETags, but its response-planning contract accepted onlyRangeandIf-Range. Bothsrc/gateway/control-ui.tsandsrc/gateway/managed-image-attachments.tsconsequently resent complete or partial representations for a matching browser validator. Assistant media additionally advertisesCache-Control: no-cache, so every ordinary browser revalidation retransmitted the full file.RFC 9110 section 13.1.2 requires matching
If-None-Matchvalidators onGETorHEADto produce304; section 13.2.2 evaluates representation preconditions before byte ranges. The existing avatar sibling already implemented the correct weak-comparison contract privately. This refactor moves that contract intosrc/gateway/http-conditional.tsand makes the avatar and both media owners consume the same authoritative decision.Verification
e051a7bb4a6ba69b87391e990b00813114b1d482.codex/qa100-gateway-media-conditional.c9f8e8de9c968a4cd38c1f07553162b4a3469709; its direct parent and merge base are the frozen canonical baselinee051a7bb4a6ba69b87391e990b00813114b1d482.GETincorrectly returned 206, while a matchingHEADincorrectly returned 200; both must return304before range processing.GET/HEADowner proof: 12 passed, zero failed.GETandHEADboth return 304 with noContent-Length, while weak validators correctly take precedence overRangeand staleIf-Range.oxfmt --checkon all nine changed paths,git diff --check, and separate fresh independent exact-head owner review: clean.Root causes fixed
1 shared media conditional-validator planning defect; two HTTP owners are affected siblings, not two separate roots.