Skip to content

fix(gateway): apply conditional requests consistently to media - #116880

Merged
steipete merged 1 commit into
mainfrom
codex/qa100-gateway-media-conditional
Jul 31, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa100-gateway-media-conditional

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Summary

  • Fix one shared Gateway media-validator root cause affecting both assistant-media downloads and managed outgoing attachments.
  • Extract the already-working avatar validator into one canonical lightweight HTTP conditional owner; remove duplicate matching logic across all three Gateway representation owners.
  • Honor exact, weak, wildcard, comma-list, and repeated If-None-Match validators for both GET and HEAD before considering Range or If-Range.
  • Return a bodyless 304 Not Modified without Content-Length, close the existing verified file descriptor, and preserve stale-validator 206 ranges, authentication, path ownership, playback behavior, and cache policy.

Root cause

src/gateway/http-byte-range.ts generated and advertised strong media ETags, but its response-planning contract accepted only Range and If-Range. Both src/gateway/control-ui.ts and src/gateway/managed-image-attachments.ts consequently resent complete or partial representations for a matching browser validator. Assistant media additionally advertises Cache-Control: no-cache, so every ordinary browser revalidation retransmitted the full file.

RFC 9110 section 13.1.2 requires matching If-None-Match validators on GET or HEAD to produce 304; 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 into src/gateway/http-conditional.ts and makes the avatar and both media owners consume the same authoritative decision.

Verification

  • Frozen canonical baseline: e051a7bb4a6ba69b87391e990b00813114b1d482.
  • Branch: codex/qa100-gateway-media-conditional.
  • Candidate commit: c9f8e8de9c968a4cd38c1f07553162b4a3469709; its direct parent and merge base are the frozen canonical baseline e051a7bb4a6ba69b87391e990b00813114b1d482.
  • Current-main owner reproduction: a matching GET incorrectly returned 206, while a matching HEAD incorrectly returned 200; both must return 304 before range processing.
  • Exact rebased commit shared conditional/byte owner and existing avatar sibling proof: 48 passed, zero failed.
  • Separate exact rebased commit assistant and managed-media authenticated real HTTP GET/HEAD owner proof: 12 passed, zero failed.
  • Full actual Gateway HTTP transport E2E on the identical patch before its conflict-free rebase: 1 passed; ticketed conditional GET and HEAD both return 304 with no Content-Length, while weak validators correctly take precedence over Range and stale If-Range.
  • Genuine TruffleHog 3.96.0 scanned all nine changed files (396,209 bytes; zero verified or unverified secrets). Targeted oxfmt --check on 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.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Jul 31, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 31, 2026
@clawsweeper

clawsweeper Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 31, 2026, 10:45 AM ET / 14:45 UTC.

ClawSweeper review

What this changes

The PR makes Gateway assistant and managed media return 304 Not Modified for matching If-None-Match requests before applying byte-range handling, using the avatar path’s shared validator logic.

Merge readiness

⚠️ Needs maintainer review before merge - 5 items remain

Keep 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 maintainer label, an out-of-date branch, in-progress checks, and a local read-only sandbox failure prevent a high-confidence current-main and history verdict.

Priority: P2
Reviewed head: c9f8e8de9c968a4cd38c1f07553162b4a3469709
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The proof is specific and useful, while a rebase plus current-main ownership review is still needed before merge confidence can rise.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body reports authenticated Gateway HTTP GET/HEAD evidence with observed 304 results and the supplied check state marks real-behavior proof successful.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports authenticated Gateway HTTP GET/HEAD evidence with observed 304 results and the supplied check state marks real-behavior proof successful.
Evidence reviewed 4 items Focused branch change: The supplied PR diff adds one shared If-None-Match helper, applies it to byte-response planning, and updates the two media handlers plus the existing avatar owner to use that shared decision.
Changed-path regression coverage: The supplied patch adds GET and HEAD coverage for weak validators preceding Range and If-Range in the byte planner, assistant-media handler, managed-media handler, and Control UI HTTP E2E path.
Contributor real-behavior evidence: The PR body reports authenticated real HTTP GET and HEAD proof showing matching validators produce bodyless 304 responses before range processing; the supplied check list also marks Real behavior proof successful.
Findings None None.
Security None None.

How this fits together

Gateway 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
Loading

Decision needed

Question Recommendation
After rebasing this maintainer-labeled Gateway HTTP change onto current main, should the shared conditional-validator refactor be accepted as the canonical response-planning path for avatar, assistant-media, and managed-media handlers? Rebase and complete review: Recommended: refresh the branch, wait for exact-head checks, and have a Gateway owner verify the shared helper against current callers before merge.

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

  • Resolve merge risk (P1) - The branch is behind current main; the supplied context marks several checks in progress, so maintainers need a rebase and exact-head review before landing.
  • Resolve merge risk (P1) - The read-only sandbox failed before local source, caller/callee, sibling, and history inspection, leaving the claimed shared-root-cause and current-main compatibility assessment unverified.
  • Resolve merge risk (P1) - The maintainer label requires explicit maintainer handling rather than an automated cleanup or close decision.
  • Complete next step (P2) - A maintainer must rebase and confirm the shared Gateway conditional-response contract on current main; this protected-label PR is not an automated repair-lane candidate.
Agent review details

Security

None.

PR surface

Source +31, Tests +143. Total +174 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 5 47 16 +31
Tests 4 143 0 +143
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 190 16 +174

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/control-ui.http.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Rebase onto current main, preserve the shared conditional-response owner if it remains compatible with all Gateway media callers, and merge only after a maintainer confirms exact-head tests and the completed check set.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Rebase onto current main, preserve the shared conditional-response owner if it remains compatible with all Gateway media callers, and merge only after a maintainer confirms exact-head tests and the completed check set.

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.

Labels

Label changes:

  • add P2: This is a bounded Gateway media-cache correctness repair with a normal, user-visible blast radius rather than an emergency availability or security incident.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports authenticated Gateway HTTP GET/HEAD evidence with observed 304 results and the supplied check state marks real-behavior proof successful.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports authenticated Gateway HTTP GET/HEAD evidence with observed 304 results and the supplied check state marks real-behavior proof successful.

Label justifications:

  • P2: This is a bounded Gateway media-cache correctness repair with a normal, user-visible blast radius rather than an emergency availability or security incident.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports authenticated Gateway HTTP GET/HEAD evidence with observed 304 results and the supplied check state marks real-behavior proof successful.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports authenticated Gateway HTTP GET/HEAD evidence with observed 304 results and the supplied check state marks real-behavior proof successful.

Evidence

What I checked:

  • Focused branch change: The supplied PR diff adds one shared If-None-Match helper, applies it to byte-response planning, and updates the two media handlers plus the existing avatar owner to use that shared decision. (src/gateway/http-byte-range.ts:86, c9f8e8de9c96)
  • Changed-path regression coverage: The supplied patch adds GET and HEAD coverage for weak validators preceding Range and If-Range in the byte planner, assistant-media handler, managed-media handler, and Control UI HTTP E2E path. (src/gateway/http-byte-range.test.ts:90, c9f8e8de9c96)
  • Contributor real-behavior evidence: The PR body reports authenticated real HTTP GET and HEAD proof showing matching validators produce bodyless 304 responses before range processing; the supplied check list also marks Real behavior proof successful. (c9f8e8de9c96)
  • Inspection infrastructure failure: A read-only command intended to read the required skill guidance failed before execution with bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted; current-main source, Git history, scoped guidance, and maintainer notes could therefore not be independently inspected from this checkout.

Likely related people:

  • steipete: The supplied context identifies steipete as the author of the focused conditional-media repair; local feature-history inspection was unavailable, so this is routing context rather than established current-main ownership. (role: proposed gateway repair author; confidence: low; commits: c9f8e8de9c96; files: src/gateway/http-byte-range.ts, src/gateway/control-ui.ts, src/gateway/managed-image-attachments.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and let the remaining exact-head checks finish.
  • Have a Gateway-area reviewer confirm the shared helper covers all current conditional-response callers.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit d8b30b7 into main Jul 31, 2026
202 of 211 checks passed
@steipete
steipete deleted the codex/qa100-gateway-media-conditional branch July 31, 2026 15:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant