Repository navigation
fix(gateway): honor session history Accept negotiation - #116535
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 4:17 PM ET / 20:17 UTC. ClawSweeper reviewWhat this changesThe PR makes the Gateway session-history endpoint select its persistent SSE response only for an explicit, acceptable Merge readinessThe patch appears correct and resolves the substring-based SSE selection bug without changing routes, authentication, or protocol shape. It should remain open because the protected Priority: P2 Review scores
Verification
How this fits togetherGateway session history serves either a finite JSON history response or a persistent Server-Sent Events stream to authenticated HTTP clients. The request flowchart LR
Client[HTTP client] --> Accept[Accept header]
Accept --> Parser[Media-range parser]
Parser --> Decision{Explicit acceptable SSE?}
Decision -->|Yes| Stream[SSE session-history stream]
Decision -->|No| Json[Finite JSON history]
Stream --> Consumer[Client consumer]
Json --> Consumer
Decision needed
Why: The implementation is narrowly supported by the HTTP contract, but accepting an upgrade-visible representation change is a product and compatibility decision reserved for protected maintainer review. Before merge
Agent review detailsSecurityNone. PR surfaceSource +199, Tests +198. Total +397 across 4 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep strict RFC 9110 parsing, retain the finite JSON fallback for wildcard and non-exact requests, and merge only after a Gateway owner explicitly accepts the intentional response-selection compatibility change on the refreshed head. Do we have a high-confidence way to reproduce the issue? Yes from source and the supplied exact-head test evidence: the former Is this the best way to solve the issue? Yes, subject to maintainer acceptance of the compatibility boundary: centralizing quote-aware RFC 9110 media-range parsing is safer and more maintainable than adding more substring exclusions. Restoring obsolete post- AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 78fd4f99fe96. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
|
Maintainer contract decision for the remaining ClawSweeper move: skip the requested post- RFC 9110 section 12.5.1 says:
Therefore The hosted |
e6618fc to
b3355e1
Compare
|
Merged via squash.
|
* fix(gateway): parse session history Accept ranges * fix(gateway): enforce HTTP media parameter grammar * fix(gateway): honor Accept parameter ordering
What Problem This Solves
Fixes an issue where session-history HTTP clients could be switched from a finite JSON response to a persistent SSE stream when the
Acceptheader merely contained a lookalike media type, a quoted decoy, malformed parameter syntax, or an explicittext/event-stream;q=0rejection.Why This Change Was Made
Session-history negotiation now uses one quote-aware RFC 9110 media-range parser instead of substring matching. It opts into SSE only for an explicit exact
text/event-streamrange with positive effective quality, applies media parameters and specificity regardless ofqordering, and intentionally leaves wildcards on the finite JSON representation.The change is confined to representation selection for the existing endpoint. It adds no route, configuration, authentication behavior, or protocol shape.
Standards note
RFC 9110 section 12.5.1 removed the older
accept-params/accept-extgrammar. It says senders should putqlast, but recipients should process any parameter namedqas weight regardless of parameter ordering. Accordingly, this parser treats every non-qparameter—before or afterq—as a media-range parameter. Reintroducing the RFC 7231-era post-qextension rule would make valid current-standard ranges select the wrong representation.User Impact
REST and automation clients reliably receive JSON unless they explicitly request an acceptable event stream. Standards-compliant EventSource-style requests continue to receive SSE, while malformed or rejected stream ranges no longer create surprising long-lived responses.
Release-note context: Gateway session history now honors strict HTTP
Acceptnegotiation instead of opening SSE streams for rejected or lookalike media types.Evidence
text/event-streaming, quoted decoys, andtext/event-stream;q=0opening SSE through substring matching.b3355e1e6b202e269d4abcf112262ac97d686545, including valid SSE, finite JSON fallbacks, qvalue precedence/order, parameter specificity, quoted delimiters, empty slots, and malformed whitespace.tbx_01kyt9z4fwadr8hb5a6ar7k1d9; changed gate and focused suite succeeded in run 30577465815.git diff --check: clean.qrecognition.