Repository navigation
fix(gateway): honor canonical If-Modified-Since validators - #117133
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 8:52 PM ET / August 1, 2026, 00:52 UTC. ClawSweeper reviewWhat this changesThe PR adds canonical Merge readinessThis PR remains necessary: current main still evaluates only Priority: P2 Review scores
Verification
How this fits togetherGateway HTTP handlers authenticate assistant-media and managed outgoing-media requests, then pass the opened file and request validators to a shared byte-response planner. That planner selects a full, partial, unsatisfiable, or not-modified response before the descriptor-backed stream writes bytes. flowchart LR
A[Authenticated media request] --> B[Assistant or managed media route]
B --> C[Verified local file]
C --> D[Shared byte response planner]
A --> D
D --> E[Validator and range decision]
E --> F[304 metadata response]
E --> G[Descriptor-backed byte stream]
Decision needed
Why: The implementation is narrowly scoped and evidence-backed, but the protected Before merge
Agent review detailsSecurityNone. PR surfaceSource +82, Tests +341. Total +423 across 6 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep one canonical conditional-response decision in Do we have a high-confidence way to reproduce the issue? Yes, from source: current main emits Is this the best way to solve the issue? Yes. Moving request-header selection and conditional evaluation into the existing shared byte-response owner repairs both callers through one canonical flow and avoids route-specific validator policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 89394978e0a6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* origin/main: (217 commits) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133) fix(config): delete one array element per config patch delete (openclaw#116463) fix(plugins): report installed dependency health authoritatively (openclaw#117029) fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016) fix(ui): clear hidden session selection before bulk deletion (openclaw#117015) fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127) fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125) fix(models): expose runtime provider catalogs in browse views (openclaw#116857) ...
* commit 'c41f033b87545b658215a9c3bbe03f88fbaa867d': (347 commits) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133) fix(config): delete one array element per config patch delete (openclaw#116463) fix(plugins): report installed dependency health authoritatively (openclaw#117029) fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016) fix(ui): clear hidden session selection before bulk deletion (openclaw#117015) fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127) fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125) ...
…#117133) Co-authored-by: Peter Steinberger <[email protected]>
* commit '31f24547a94a8bd74a32e42cde1783591c5804d9': (347 commits) refactor(plugins): consolidate descriptor and startup ownership (openclaw#117146) fix(messages): reply actions leak citation markers and reply/poll answers draw the no-reply fallback (openclaw#116909) fix(slack): let durable ingress retry transient thread lookups (openclaw#117135) refactor(doctor): consolidate shipped state migration ownership (openclaw#117142) fix(ai): Codex stream shows internal parser text on a malformed frame (openclaw#116966) fix: guard every migrated session accessor path (openclaw#117140) fix(terminal): measure unicode display width consistently (openclaw#117062) fix(openai): clear ChatGPT SSE fallback per session (openclaw#117123) fix(mistral): reject incomplete streamed tool terminals (openclaw#117137) fix(ai): preserve structured chat content and refusals (openclaw#117136) fix(doctor): persist normalized agent roster (openclaw#117115) fix(signal): avoid replay after ambiguous quote delivery errors (openclaw#117134) fix(cron): reject disabled delivery accounts when scheduling (openclaw#116899) fix(gateway): honor HTTP If-Modified-Since media validators (openclaw#117133) fix(config): delete one array element per config patch delete (openclaw#116463) fix(plugins): report installed dependency health authoritatively (openclaw#117029) fix(ui): recover moving sessions across paged gateway rosters (openclaw#117016) fix(ui): clear hidden session selection before bulk deletion (openclaw#117015) fix(discord): avoid replaying ambiguous voice deliveries (openclaw#117127) fix(ui): scope Gateway reconnect lineage to its target (openclaw#117125) ...
What Problem This Solves
Authenticated assistant-media and managed-media responses publish
Last-Modifiedbut ignored everyIf-Modified-Sincerequest. Browser caches therefore re-downloaded unchanged images, audio, and video instead of receiving a bodyless304 Not Modified; ranged requests could also transfer bytes before evaluating the date validator.Independent real bearer-authenticated production HTTP against frozen
maine857d8e5c690814ebd0d5e4e84d32174a537fdfareproduced 24 incorrect responses across both routes,GET,HEAD, all three valid HTTP-date formats, range precedence, and future-dated files.Why This Change Was Made
The canonical Gateway byte-response owner already controlled ETags,
Last-Modified,Range,If-Range, and descriptor lifetimes. Its private request contract omittedIf-Modified-Since, and both route callers duplicated incomplete header selection.This refactor gives that existing owner one canonical Node HTTP-request contract and removes the duplicated three-header extraction from both callers. It obtains
If-Modified-Sinceexclusively from Node's authoritativeheadersDistinctcollection: Node silently discards duplicate singleton fields from normalizedheaders, so a date is accepted only when exactly one wire field exists. Its file-private HTTP-date parser strictly accepts IMF-fixdate, obsolete RFC 850, and ANSI Casctime; validates weekday, real calendar date, UTC, minimum four-digit year, leap seconds, and RFC 850's rolling 50-year rule. It compares against the actual second-precision, future-clampedLast-Modifiedemitted by that same response.If-None-Matchalways takes precedence whenever present, including empty or nonmatching values. Invalid/multiple dates are ignored. Existing ETags, strong/dateIf-Range, range outcomes,304metadata,401,416, authentication, and descriptor ownership remain unchanged.The full repair stays within three existing private production files. The two oversized route owners each become two lines shorter; there is no public API, protocol, configuration, authentication, security, persistent-state, SDK, AI/package dependency, fallback, or compatibility-shim change.
Protocol: RFC 9110 §5.6.7, HTTP-date, RFC 9110 §13.1.3, If-Modified-Since, and Node.js IncomingMessage.headersDistinct.
User Impact
304responses for valid conditionalGETandHEAD, avoiding duplicate transfers.Evidence
Frozen current-main base:
e857d8e5c690814ebd0d5e4e84d32174a537fdfa.Final immutable candidate:
de6e3fa773cc768b1614c7000c4a316055974b09.Regression-first and focused owner/sibling suites
304responses on both routes; the final canonicalrequestcontract uses authoritativeheadersDistinctand exact-one validation, with mixed-case duplicate-wire regressions.oxlint --type-aware --type-checkon all six changed files, targetedoxfmt --check, andgit diff --checkpassed.Real authenticated production HTTP
An independently owned proof started actual loopback TCP servers and exercised the unmocked assistant-media and managed-media production handlers with real bearer-authenticated requests, real files, past/future mtimes, full/ranged
GET, andHEAD.{"candidate":"de6e3fa773cc768b1614c7000c4a316055974b09","actualProductionAssertions":301,"strictIndependentDateOracleAssertions":74,"totalIndependentAssertions":375,"routes":["assistant-media","managed-media"],"baselineIncorrectResponses":24,"conditionalStatuses":[304,200,206,416,401],"validDateFormats":["IMF-fixdate","RFC850","asctime"],"bodyless304":true,"futureClampedLastModified":true,"etagPresencePrecedence":true,"duplicateRawWireFieldsIgnored":true}All 301 actual production HTTP assertions and 74 independent adversarial HTTP-date oracle assertions passed. Genuine bearer-authenticated raw
net.Socketrequests exercised mixed-case, identical, triple, reversed, and comma-folded duplicate wire headers against both production routes and both methods; duplicate values never produced a false304. Every legitimate304omitted body,Content-Length, andContent-Rangewhile retaining ETag and the authoritative emittedLast-Modified. Invalid dates,0000/0025/0099years, wrong weekdays, impossible dates, rolling2050/1977, and leap-second boundary cases were independently checked.Review
Two independently acting agents reviewed the entire exact immutable owner, both complete route callers, sibling ETag/range implementations, direct Node/file/descriptor dependency behavior, scoped guidance, current
main, and current RFC semantics. Both returned zero P0/P1/P2/P3 findings, confidence 0.99; the first personally reran the complete 271/271 suites, a 26/26 adversarial oracle, and 10/10 real mixed-case raw HTTP assertions.Genuine complete-branch
autoreview --mode branch --base e857d8e5c690814ebd0d5e4e84d32174a537fdfa --max-priority P3: zero P0/P1/P2/P3 findings, TruffleHog clean, verdict patch is correct, confidence 0.98.