Skip to content

fix(media): preserve size errors for fractional byte limits - #136402

Merged
steipete merged 2 commits into
mainfrom
codex/qa30b-response-bytes
Sep 2, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/qa30b-response-bytes

Conversation

@steipete

@steipete steipete commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes #136397
Related: #135418

What Problem This Solves

Fixes an issue where users downloading media under a decimal MiB limit receive a generic fetch failure instead of the size-limit error. Bounded diagnostic text reads can also throw instead of returning their truncated prefix.

Why This Change Was Made

The shared HTTP response reader tracked a sliced chunk using a fractional budget remainder, then passed that fractional length to Buffer.concat. It now counts observed bytes once and derives the retained whole-byte length. The redundant counter, single-use validation wrapper, and success-path error factory are removed; timeout forwarding, cancellation, and configured limits retain their existing behavior.

This is a maintainer-owned replacement approach for the fractional-limit problem investigated by @ly85206559 in #135418. Repairing the reader covers all valid fractional byte-budget callers without adding channel fallback policy or changing positive sub-byte limits. Contributor credit is preserved in the commit.

User Impact

Oversized chunked downloads are correctly classified as size-limit failures. Downloads within the limit still succeed, and diagnostic prefixes return only complete retained bytes. No configuration or migration is required.

Evidence

  • Real Node 24.19.0 HTTP/Fetch reproduction: a 0.1 MiB budget resolves to 104857.6 bytes. A 104857-byte chunked response succeeds before and after; a 104858-byte response changes from fetch_failed/RangeError to max_bytes.
  • Four new regression cases fail on the original code. All 134 tests pass across bounded response reads, guarded-fetch release/capture behavior, and media fetches.
  • node scripts/check-changed.mjs passes, including production and test type checks, lint, boundary checks, and runtime guards.
  • Independent Codex review through P2 reports no accepted/actionable findings. Production: 12 added, 22 deleted (net −10). Tests: 28 added, 1 deleted (net +27).
  • Current head: e3a8c87f40058206d36babd6233b22b613ed112d; production is unchanged from the original reviewed head.

CI follow-up

The hosted retry exposed two unrelated corner-style assertions that distinguished round from the equivalent computed value superellipse(1). The CSS Borders draft defines them as the same shape. The existing browser probe now normalizes that exact alias; distinct curvature, radii, and root-token expectations are unchanged. Local Chromium reports both assignments as round, while the retained hosted log reports superellipse(1).

All three corner browser cases pass locally after the correction; formatting and an independent P2 supplement are clean. The new head still requires hosted CI. This is test portability maintenance, with no additional product bug claimed.

Track observed response bytes once and derive the retained whole-byte length.
Keep timeout projection, cancellation, and diagnostics unchanged.

Fixes #136397
Related: #135418
Co-authored-by: ben.li <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 2, 2026
@steipete
steipete marked this pull request as ready for review September 2, 2026 15:53
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 2, 2026, 1:18 PM ET / 17:18 UTC.

ClawSweeper review

What this changes

The PR makes the shared HTTP response reader retain whole-byte prefixes for fractional limits while preserving overflow errors, and normalizes an equivalent Chromium CSS serialization in a browser test.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. Current main still passes a fractional retained-byte count to Buffer.concat, so the linked media error-classification problem remains; the branch repairs that owner boundary and adds focused regression coverage. The maintainer-authored, maintainer-labeled PR should proceed through normal exact-head CI and maintainer handling.

Priority: P2
Reviewed head: e3a8c87f40058206d36babd6233b22b613ed112d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch directly repairs the current shared-reader failure and has focused regression coverage; exact-head hosted CI remains pending.
Proof confidence 🌊 off-meta tidepool Not applicable: Repository State identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; its body nevertheless records a real Node 24 HTTP/Fetch before-and-after scenario for the changed reader path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Repository State identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; its body nevertheless records a real Node 24 HTTP/Fetch before-and-after scenario for the changed reader path.
Evidence reviewed 5 items Current-main defect: Current main accumulates the fractional remainder into total and passes it as the explicit Buffer.concat length, leaving the reported fractional-limit failure path present.
Owner-boundary repair: The branch records actual bytes observed in size and derives the retained allocation length as a whole number, preserving the observed size for overflow reporting.
Media caller behavior: The media fetch path supplies a MediaFetchError with code max_bytes through onOverflow; unexpected reader errors are otherwise converted to generic fetch failures, which makes preserving the overflow path material.
Findings None None.
Security None None.

How this fits together

Media downloads and diagnostic captures feed streamed HTTP responses into a shared bounded reader, which either returns retained bytes or reports an overflow to its caller. The browser test separately compares computed CSS values across Chromium serialization variants.

flowchart LR
A[Chunked HTTP response] --> B[Bounded response reader]
B --> C{Limit exceeded?}
C -->|No| D[Complete buffer]
C -->|Yes| E[Whole-byte prefix]
E --> F[Size-limit error]
G[Computed CSS value] --> H[Browser style probe]
H --> I[Portable assertion]
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head hosted checks are still queued, so the reported local test and browser-portability results are not yet independently confirmed by CI.
Agent review details

Security

None.

PR surface

Source -10, Tests +27. Total +17 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 12 22 -10
Tests 2 28 1 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 40 23 +17

Review metrics

Metric Value Why it matters
Production vs test LOC production -10; tests +27 The bug fix simplifies the shared production reader while adding focused HTTP and browser portability coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #136397
Summary: This PR is the candidate fix for the linked decimal media-limit issue; the other open PR addresses related configuration-side normalization rather than replacing this reader repair.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared reader as the sole fractional-byte repair point, retain the focused regressions, and land after the exact head receives normal maintainer and CI validation.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the shared reader as the sole fractional-byte repair point, retain the focused regressions, and land after the exact head receives normal maintainer and CI validation.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: a fractional maxBytes reaches the current-main Buffer.concat length through the shared streamed-reader path, and the new focused tests exercise the affected cases. The PR body also supplies a real Node/Fetch reproduction, though this read-only review did not rerun it.

Is this the best way to solve the issue?

Yes. Repairing the shared response-reader allocation calculation preserves the caller's max_bytes error rather than rounding only one media configuration path and leaving diagnostic-prefix callers exposed.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 284805b371ec.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a bounded media-download error classification defect with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Repository State identifies this as a maintainer-authored PR, so the external-contributor proof gate does not apply; its body nevertheless records a real Node 24 HTTP/Fetch before-and-after scenario for the changed reader path.

Evidence

What I checked:

  • Current-main defect: Current main accumulates the fractional remainder into total and passes it as the explicit Buffer.concat length, leaving the reported fractional-limit failure path present. (src/infra/http-body.ts:213, 284805b371ec)
  • Owner-boundary repair: The branch records actual bytes observed in size and derives the retained allocation length as a whole number, preserving the observed size for overflow reporting. (src/infra/http-body.ts:181, e3a8c87f4005)
  • Media caller behavior: The media fetch path supplies a MediaFetchError with code max_bytes through onOverflow; unexpected reader errors are otherwise converted to generic fetch failures, which makes preserving the overflow path material. (src/media/fetch.ts:729, 284805b371ec)
  • Regression coverage: New table-driven cases cover fractional overflow classification and whole-byte diagnostic prefixes for sub-byte and partial-byte budgets. (src/infra/http-body.response.test.ts:189, e3a8c87f4005)
  • Recent area history: Recent main history attributes the adjacent HTTP-body refactors to Peter Steinberger; the proposed repair commit is also by that author. (src/infra/http-body.ts:162, c47f102224f9)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-02T16:00:59.718Z sha 0e29ee8 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 2, 2026
@steipete
steipete merged commit f7c8217 into main Sep 2, 2026
307 of 308 checks passed
@steipete
steipete deleted the codex/qa30b-response-bytes branch September 2, 2026 19:19
@steipete

steipete commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 3, 2026
…#136402)

* fix(media): preserve size errors for fractional byte limits

Track observed response bytes once and derive the retained whole-byte length.
Keep timeout projection, cancellation, and diagnostics unchanged.

Fixes openclaw#136397
Related: openclaw#135418
Co-authored-by: ben.li <[email protected]>

* test(ui): compare equivalent circular corner serialization

---------

Co-authored-by: ben.li <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

Chunked media downloads misreport decimal MiB size limits

1 participant