GeezerVison is showing github.com — fix(id): let a max-size image fit the upload route's body limit by dezren39 · Pull Request #747 · developing-today/code
Conversation
dezren39
commented
Oct 24, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #716
Problem
The web UI's MAX_IMAGE_SIZE (10 MiB, web/src/image-upload.ts) is a file limit, but the server's identical 10 MiB DefaultBodyLimit applied to the whole multipart request body. A file of exactly 10 MiB produces a ~10 MiB + 170 byte body (more with longer filenames), so the largest image the UI explicitly accepts was rejected by the server with a generic upload error.
Solution (pkgs/id/src/web/routes.rs only)
- Named constants:
MAX_IMAGE_SIZE (10 MiB, documented as required to stay equal to the client constant), UPLOAD_MULTIPART_ALLOWANCE (1 MiB), UPLOAD_BODY_LIMIT (11 MiB), DEFAULT_BODY_LIMIT (10 MiB).
/api/upload gets a route-scoped DefaultBodyLimit::max(UPLOAD_BODY_LIMIT) which overrides the router-wide limit for that route only — /api/save and the other POST routes keep 10 MiB.
upload_handler checks the file itself against MAX_IMAGE_SIZE and returns 413 with a clear Image too large: N bytes exceeds the maximum image size of 10485760 bytes (10 MiB) message; multipart length-limit errors in the field/bytes reads map to the same clear 413 instead of a generic 400.
- New test
test_upload_body_limit_fits_max_image_plus_multipart_overhead pins the relationship (body limit must fit a max-size file + the multipart overhead of a 255-byte filename; router limit stays 10 MiB) so the two limits cannot drift back into conflict.
Verification
Single-repo: the upload route and client constant exist only in this repo.
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Need help on this PR? Tag @codesmith-bot with what you need.
Update 2026-10-24 (issue-sweep, fixes #751)
Fixes #751
Summary by CodeRabbit
- Bug Fixes
- Uploads now support images up to 10 MiB, with additional room for multipart overhead. Requests that exceed the upload or image-size limits receive a 413 response with an image-size message; other multipart parsing errors continue to receive a 400 response.
- Other routes have a 10 MiB request-body limit.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The client MAX_IMAGE_SIZE (10 MiB) is a file limit, but the router-wide
DefaultBodyLimit counted the whole multipart body, so an image at (or
~200 bytes under) the advertised max was rejected by the server.
- /api/upload gets a route-scoped DefaultBodyLimit of 11 MiB
(MAX_IMAGE_SIZE + 1 MiB multipart-envelope allowance); all other
routes keep the 10 MiB router limit.
- upload_handler now checks the file itself against MAX_IMAGE_SIZE and
returns a clear 413 'Image too large' message; multipart length-limit
errors map to the same 413 instead of a generic 400.
- New test pins the relationship: UPLOAD_BODY_LIMIT must fit a max-size
file plus the multipart overhead of a 255-byte filename, and the
router-wide limit stays 10 MiB.
coderabbitai
Bot
commented
Oct 24, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Recent review info
-
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:
00bd12b2-66c6-4726-a4ce-768690edf3ab
Commits
-
Reviewing files that changed from the base of the PR and between 85f0bb5 and 318792e.
Files selected for processing: 2
-
pkgs/id/src/store_traits.rs
pkgs/id/src/web/routes.rs
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
Walkthrough
-
The upload route now separates the per-file maximum from the multipart request-body limit. Oversized uploads receive size-related 413 responses, and other multipart errors remain 400. Tests cover these outcomes and the limit relationship.
Changes: Upload limits
| Layer / File(s) |
Summary |
Upload body limits pkgs/id/src/web/routes.rs |
The /api/upload route uses a body limit that includes multipart allowance. Other routes use the 10 MiB default limit. |
Upload validation and responses pkgs/id/src/web/routes.rs, pkgs/id/src/store_traits.rs |
Upload size-limit failures and files above the per-file maximum return 413; other multipart errors return 400. Tests cover those responses, maximum-size uploads, and limit configuration. Two get_latest_entry_tx test assertions were reformatted without changing their expectations. |
Priority: Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix · Severity of issue fixed: Medium
Possibly related issues
Possibly related PRs
- developing-today/code#711 — The PR includes formatting-only changes in
store_traits.rs, which connect to the formatter checks addressed by this PR.
Merge Risk: Minimal · up to 31879
-
No merge-blocking issue is established for the upload-limit change; normal checks remain appropriate.
Pre-merge checks: 2 · 2 · 1
-
Failed checks: 2 warnings · 1 inconclusive
| Check name |
Status |
Explanation |
Resolution |
| Out of Scope Changes check |
 |
pkgs/id/src/store_traits.rs contains formatting-only changes to unrelated assertions. These changes do not implement or test issue #716's upload-limit behavior. The PR description identifies them as… |
Remove the store_traits.rs formatting changes from this PR, or move them to a separate formatting pull request. |
| Docstring Coverage |
 |
Docstring coverage is 27.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 2 files. |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
| Linked Issues check |
 |
Issue #716 requires the exact 10 MiB file to upload, a clear 413 for oversized files, a limit-relationship test, and passing existing upload tests. The reviewed summary and routes.rs evidence show a… |
Provide successful CI results for the Rust web route tests and the existing image-upload tests, or provide a successful local test execution. |
Passed checks: 2 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title clearly and concisely describes the main change: allowing a maximum-size image to fit within the upload route's body limit. |
Full details: Out of Scope Changes check
-
Explanation
pkgs/id/src/store_traits.rs contains formatting-only changes to unrelated assertions. These changes do not implement or test issue #716's upload-limit behavior. The PR description identifies them as a ride-along CI formatting fix, not as upload support.
Resolution
Remove the store_traits.rs formatting changes from this PR, or move them to a separate formatting pull request.
Full details: Linked Issues check
-
Explanation
Issue #716 requires the exact 10 MiB file to upload, a clear 413 for oversized files, a limit-relationship test, and passing existing upload tests. The reviewed summary and routes.rs evidence show a route-scoped 11 MiB limit, a 10 MiB file limit, preservation of the 10 MiB limit for other routes, and tests for exact-limit, body-limit, file-limit, and malformed multipart cases. Test execution was blocked by linker OOM, and no CI result is supplied. Passing the required existing tests is therefore not established.
Resolution
Provide successful CI results for the Rust web route tests and the existing image-upload tests, or provide a successful local test execution.
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning Some tools did not complete. Review the errors below.
🔧 Clippy (1.99.0)
-
Clippy execution timed out
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
-
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…:status() (#751)
PR #747's is_body_limit_error substring-matched MultipartError's
Display, which in axum 0.8 is the constant string 'Error parsing
multipart/form-data request' for every error — so the promised clear
413 for over-body-limit uploads could never fire and they fell through
to a generic 400. Classify via err.status() == 413 instead, which axum
derives from the underlying multer length-limit errors.
New upload_router_tests drive real multipart bodies through
create_router: over UPLOAD_BODY_LIMIT -> clear 413, exactly
MAX_IMAGE_SIZE -> 200, over MAX_IMAGE_SIZE under the body limit ->
explicit 413, malformed multipart -> 400.
These two long assert_eq! lines landed unformatted via PR #739 and now
fail the rustfmt-check leg of nix flake check for every id PR
(#746/#747/#750 all fail on this alone). Formatting-only; rides along
here because this PR's flake leg cannot pass until main's file is
formatted.
|
Verification update (issue-sweep 2026-10-24): the local test run has now completed on this exact head — cargo test --features web,ssh --lib upload_router_tests = 4/4 PASS (over body limit → clear 413, exactly MAX_IMAGE_SIZE → 200, over MAX under body limit → explicit 413, malformed → 400), plus cargo check --features web,ssh --lib --tests PASS and rustfmt clean.
The nix flake check failure on this head (run 40093501759) is infra-only: Magic Nix Cache throttled / GitHub API rate limit (HTTP 418 narinfo downloads, 'GitHub Actions Cache throttled Magic Nix Cache') — no check actually ran, same failure shape as PR #746 attempt 1. The rustfmt-check blocker that failed this leg on the previous head is fixed in this PR (treefmt + evaluation + run + CodeRabbit all PASS here).
Merging per Drew's standing directive (change verified sound locally incl. test execution; infra failure recorded in the sweep backlog). Post-merge main CI is the watch item for the flake leg.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Oct 24, 2026
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|