Skip to content

pm-dispatch: measure body cap in UTF-8 bytes in readJsonBody (#3010) - #3682

Merged
dezren39 merged 1 commit into
mainfrom
queue/5517-3010-body-bytes
Nov 1, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5517-3010-body-bytes

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #3010. Queue task 5517 (implementation by lane B; PR opened on resume by lane E after GitHub's content-creation throttle lifted).

What

pm-stack/dispatch/src/server.ts readJsonBody enforced MAX_BODY_BYTES (256 KiB) against text.length — UTF-16 code units, not bytes — so a multibyte body up to ~3x the stated cap passed the only intake size guard (triage 4357 runtime check: 100,000 CJK chars = 100,000 code units but 300,000 UTF-8 bytes vs the 262,144 cap).

Now the cap is measured in UTF-8 bytes (TextEncoder), same cap value, same ValidationError('body: too large') behaviour; ASCII behaviour is byte-identical (1 unit = 1 byte). No streaming/early-abort change (pinned scope).

Tests

4 new boundary tests in pm-stack/dispatch/test/server.test.ts; dispatch suite 90 pass (run by lane B on the laptop at c97bfc1):

  • multibyte body just under the cap in bytes passes
  • body under the cap in code units but over in bytes is rejected with 'body: too large'
  • ASCII at/over-cap behaviour unchanged

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

readJsonBody enforced MAX_BODY_BYTES (256 KiB) as text.length, which counts UTF-16 code units — a 300 KB CJK body passed the too-large check. Measure new TextEncoder().encode(text).length against the same cap, same ValidationError. Boundary tests in server.test.ts: CJK over-in-bytes rejected, CJK just-under-in-bytes passes the size gate, ASCII over/under unchanged. Full dispatch suite: 90 pass.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 12:37
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a823e32-6875-418b-b8d0-869c19488234
Commits

Reviewing files that changed from the base of the PR and between 9df0b20 and c97bfc1.

Files selected for processing: 2
  • pm-stack/dispatch/src/server.ts
  • pm-stack/dispatch/test/server.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T12:39:22.915949Z c97bfc1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit e8a360b into main Nov 1, 2026
1 check passed
@dezren39
dezren39 deleted the queue/5517-3010-body-bytes branch November 1, 2026 12:41
@dezren39
dezren39 restored the queue/5517-3010-body-bytes branch November 8, 2026 04:18
@dezren39
dezren39 deleted the queue/5517-3010-body-bytes branch November 8, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pm-dispatch(server): the 256 KiB body cap is measured in UTF-16 code units, not bytes — a 300 KB CJK body passes readJsonBody's 'too large' check

1 participant