Title: id(web): images at the advertised 10 MiB max pass the client check but are rejected by the server's 10 MiB whole-body limit · Issue #716 · developing-today/code · GitHub
Open Graph Title: id(web): images at the advertised 10 MiB max pass the client check but are rejected by the server's 10 MiB whole-body limit · Issue #716 · developing-today/code
X Title: id(web): images at the advertised 10 MiB max pass the client check but are rejected by the server's 10 MiB whole-body limit · Issue #716 · developing-today/code
Description: Summary An image at (or just under) the client's advertised 10 MiB maximum passes the web UI's size check but is rejected by the server, because the client's limit applies to the file while the server's identical 10 MiB limit applies to ...
Open Graph Description: Summary An image at (or just under) the client's advertised 10 MiB maximum passes the web UI's size check but is rejected by the server, because the client's limit applies to the file while the ser...
X Description: Summary An image at (or just under) the client's advertised 10 MiB maximum passes the web UI's size check but is rejected by the server, because the client's limit applies to the file w...
Opengraph URL: https://github.com/developing-today/code/issues/716
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web): images at the advertised 10 MiB max pass the client check but are rejected by the server's 10 MiB whole-body limit","articleBody":"## Summary\n\nAn image at (or just under) the client's advertised 10 MiB maximum passes the\nweb UI's size check but is rejected by the server, because the client's limit\napplies to the **file** while the server's identical 10 MiB limit applies to\nthe **whole multipart request body**, whose encoding adds overhead the file\nbudget does not account for.\n\n## Evidence (verified on main `26c54292`, 2026-10-23)\n\n- Client: `pkgs/id/web/src/image-upload.ts:34` — `MAX_IMAGE_SIZE = 10 * 1024 * 1024`;\n paste/drop handlers skip a file only when `file.size > MAX_IMAGE_SIZE`\n (`image-upload.ts:170` and `:198`), so a file of exactly 10 MiB is uploaded.\n The constant is pinned by `image-upload.test.ts:43-49`.\n- Server: `pkgs/id/src/web/routes.rs:265` — the whole router is layered with\n `DefaultBodyLimit::max(10 * 1024 * 1024)`. `upload_handler`\n (`routes.rs:1272`) has no size check of its own, so the body limit is the\n only server-side bound and it counts every byte of the multipart envelope.\n- Measured with Node's `FormData`/`Request` (the same encoding the browser\n produces) for a file named `photo.png`:\n - file size 10,485,760 → multipart body 10,485,930 bytes (**170 bytes of\n overhead**: boundary, `Content-Disposition` with the filename, part\n `Content-Type`, closing boundary). Over the server limit → rejected.\n - file size 10,485,660 (100 bytes *under* the advertised max) → body\n 10,485,830 → still rejected.\n - file size 10,485,560 → body 10,485,730 → accepted.\n So the effective maximum is ≈200 bytes below the advertised one, and it\n shrinks further with longer filenames. The user sees only a generic\n `Upload failed (…)` error from `uploadImageFile` with no hint that a file\n the UI explicitly allowed is \"too large\".\n\n## Why it matters\n\nThe two sides disagree about what the limit measures, so the boundary of the\ndocumented feature is broken in exactly the range a user who checks the limit\nwill hit: a 10 MiB image (a common phone-photo size class) is promised by the\nclient and refused by the server. The failure mode is silent/confusing rather\nthan a clear \"image too large\" message.\n\n## Acceptance criteria\n\n- [ ] A file of exactly `MAX_IMAGE_SIZE` bytes (10 MiB) with a typical\n filename uploads successfully end to end, **or** the client limit is\n lowered/documented so the largest client-accepted file always fits the\n server body limit (including multipart overhead for long filenames).\n- [ ] The server rejects an over-limit file with a clear size-related error\n (not a generic multipart/body error leaking through `upload_handler`).\n- [ ] A test pins the relationship between the two limits (e.g. a Rust test\n asserting the upload route's effective body limit exceeds the client\n `MAX_IMAGE_SIZE` plus a multipart-overhead allowance, or a client test\n for the adjusted constant) so the two cannot drift back into conflict.\n- [ ] Existing `image-upload` web tests and the Rust web route tests still pass.\n\nSuggested fix direction: raise the body limit for the `/api/upload` route\nonly (route-scoped `DefaultBodyLimit` above 10 MiB + overhead, e.g. 11 MiB)\nand/or add an explicit file-size check in `upload_handler` returning\n`413` with a clear message — rather than raising the global router limit,\nwhich also guards `/api/save` and the other POST routes.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-24T04:37:19Z","url":"https://github.com/developing-today/code/issues/716"}
| 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:a837040c-b0db-7b0c-0155-90b5cbd8ccdf |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D124:3B6B85:CBEB14:10822C5:6B064168 |
| html-safe-nonce | 0c881915d2efd1d44435fc568d630723c325c974817fd2edda47086800f605f4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTI0OjNCNkI4NTpDQkVCMTQ6MTA4MjJDNTo2QjA2NDE2OCIsInZpc2l0b3JfaWQiOiIzMDc2OTIwODk0ODQxODMxNzg0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | e7255ec93af45225ebee9f2beda39e656e4ce767b65defbce026a7110dfac87f |
| hovercard-subject-tag | issue:6009375933 |
| 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/716/issue_layout |
| twitter:image | https://opengraph.githubassets.com/272df2bae45e733c4f0dbc6048bef4e265648f955fa44ab46705852bda812080/developing-today/code/issues/716 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/272df2bae45e733c4f0dbc6048bef4e265648f955fa44ab46705852bda812080/developing-today/code/issues/716 |
| og:image:alt | Summary An image at (or just under) the client's advertised 10 MiB maximum passes the web UI's size check but is rejected by the server, because the client's limit applies to the file while the ser... |
| 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 | 1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652 |
| 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 | ac613d3698d3d8565651455086e1f74da07bf277 |
| 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