Title: 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 · Issue #3010 · developing-today/code · GitHub
Open Graph Title: 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 · Issue #3010 · developing-today/code
X Title: 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 · Issue #3010 · developing-today/code
Description: Problem pm-dispatch's request body cap is named and documented as a byte cap, but it is measured in UTF-16 code units — so a body well over the cap in bytes passes the check whenever the prompt text is non-ASCII. Evidence pm-stack/dispat...
Open Graph Description: Problem pm-dispatch's request body cap is named and documented as a byte cap, but it is measured in UTF-16 code units — so a body well over the cap in bytes passes the check whenever the prompt tex...
X Description: Problem pm-dispatch's request body cap is named and documented as a byte cap, but it is measured in UTF-16 code units — so a body well over the cap in bytes passes the check whenever the prompt...
Opengraph URL: https://github.com/developing-today/code/issues/3010
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"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","articleBody":"## Problem\n\npm-dispatch's request body cap is named and documented as a byte cap, but it is measured in UTF-16 code units — so a body well over the cap in bytes passes the check whenever the prompt text is non-ASCII.\n\n## Evidence\n\n- `pm-stack/dispatch/src/server.ts:36` (main `fbfd1454`): `const MAX_BODY_BYTES = 256 * 1024;`\n- `server.ts:47-48`, `readJsonBody`: `const text = await req.text(); if (text.length > MAX_BODY_BYTES) throw new ValidationError(\"body: too large\");` — `String.length` counts UTF-16 code units, not bytes.\n- Verified this run with the runtime's own semantics: a string of 100,000 CJK characters has `length` 100,000 (≤ 262,144, so it passes) but encodes to 300,000 UTF-8 bytes — ~17% over the stated cap. Worst common cases: CJK text passes at up to ~3× the cap in bytes (786,432 bytes); astral-plane characters (emoji) at up to ~2× (2 code units per 4-byte character, 524,288 bytes).\n\n## Why it matters\n\n- The cap is the intake boundary's only size guard before `JSON.parse` and packet construction on both authenticated endpoints (`POST /v1/sessions`, `POST /v1/tasks`). Its stated unit is bytes; the enforced unit is code units, so the guard the operator thinks is in place (256 KiB) is not the guard that runs (up to ~768 KiB of actual body).\n- Dispatch prompts are exactly the traffic that goes non-ASCII: callers paste prompts with CJK text, emoji and smart punctuation, so the miscount is on the common path, not an exotic one.\n- Nothing else in the service re-checks size: the packet, issue body and queue task all carry the prompt onward at whatever size passed.\n\n## Acceptance criteria\n\n- `readJsonBody` rejects on the body's UTF-8 byte length (e.g. `new TextEncoder().encode(text).length` or `Buffer.byteLength(text)`), keeping the same `MAX_BODY_BYTES` value and the same `ValidationError(\"body: too large\")` behavior for ASCII bodies.\n- A test in `pm-stack/dispatch/test/` pins both sides of the boundary with multibyte text: a body just under the cap in bytes passes; a body under the cap in code units but over it in bytes is rejected.\n- Existing dispatch tests still pass (`bun test` in `pm-stack/dispatch`).\n\nFound by new-issue-creator-code-a, run 2026-10-31; verified by direct read of `server.ts` on main `fbfd1454` plus a runtime semantics check this run (100,000 CJK chars: length 100,000, 300,000 UTF-8 bytes). Dedup: searched open+closed issues for MAX_BODY_BYTES / dispatch body size / readJsonBody — no hits; the #2668 design doc's boundary rule covers shape/scope validation of fields, not the body-size unit.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-31T09:43:54Z","url":"https://github.com/developing-today/code/issues/3010"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5415401f-b461-f2cb-d24a-340f46fb59b2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A5DA:3C042B:348C01:44E0D6:6B0617F2 |
| html-safe-nonce | cd33226728f35a3d98990a1714284aad4eb3e6fff0c3bc7e6e4181b4aba8787e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNURBOjNDMDQyQjozNDhDMDE6NDRFMEQ2OjZCMDYxN0YyIiwidmlzaXRvcl9pZCI6IjIxNDY3NzQxNDI2NzMwOTg3MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 38e0f8881c686eb8dc77a58d80c538be9db3aa3e3250b3b763e36c7c1b63d9ec |
| hovercard-subject-tag | issue:6133449485 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/3010/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30c5567aa7a9b0ad1bf538b44e1540aeb6eced455831ead9caeeb8bd927932a5/developing-today/code/issues/3010 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30c5567aa7a9b0ad1bf538b44e1540aeb6eced455831ead9caeeb8bd927932a5/developing-today/code/issues/3010 |
| og:image:alt | Problem pm-dispatch's request body cap is named and documented as a byte cap, but it is measured in UTF-16 code units — so a body well over the cap in bytes passes the check whenever the prompt tex... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 97d4714e567728e1f85f88b0cf68c89f0f8a3dc41e8869af7aeb8195ad990374 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 866f202ebf7ac5aff8f633417d9fd8a53818a977 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width