Skip to content

fix(upload): raise Rocket data limits to match CHUNK_SIZE - #105

Merged
rubenhensen merged 1 commit into
mainfrom
fix/upload-chunk-data-limit
Apr 24, 2026
Merged

fix(upload): raise Rocket data limits to match CHUNK_SIZE#105
rubenhensen merged 1 commit into
mainfrom
fix/upload-chunk-data-limit

Conversation

@dobby-coder

@dobby-coder dobby-coder Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #38.

Rocket's default body-size limit for bytes, data-form, and file is 1 MiB. Since #104 landed with CHUNK_SIZE = 10 MiB, any chunk over 1 MiB gets rejected with "Data limit reached while reading the request body" — Rocket trims the body before the handler's data.open((end - start).bytes()) cap runs. The issue explicitly mentions this and the chunks >1 MiB failing uploads.

Fix

Merge framework-level limits onto Rocket::Config::figment() in rocket::custom(...):

let limits = rocket::data::Limits::default()
    .limit("bytes", (CHUNK_SIZE + 1024 * 1024).bytes())
    .limit("data-form", (CHUNK_SIZE + 1024 * 1024).bytes())
    .limit("file", (CHUNK_SIZE + 1024 * 1024).bytes());

1 MiB of headroom above CHUNK_SIZE for HTTP overhead. The per-request (end - start).bytes() cap in upload_chunk remains the authoritative limit — this change only lifts the framework floor that was clipping legitimate chunks.

rocket::Config::figment() still reads ROCKET_CONFIG / Rocket.toml before the merge, so existing deployed [global.*] settings continue to take effect.

Verification

  • cargo build --release — green.
  • cargo test — 5/5 pass (the existing store tests; no new tests needed for a config-only change).
  • cargo clippy --all-targets — only the pre-existing useless_format warning in src/email.rs:225.

Interactive 10 MiB upload not reproduced in the workspace — cryptify's runtime needs a live PKG at startup and a client that produces a chunked Content-Range PUT, which wasn't feasible here. The issue reporter already observed the failure mode before and explicitly asked for "dynamically change datalimit based on chunk size"; this does exactly that at framework startup. Keeping as draft so a maintainer can confirm on staging.

Reviewer quickstart

git fetch origin && git checkout fix/upload-chunk-data-limit && cargo build --release

Closes #38.

Rocket's default body-size limit for \`bytes\`, \`data-form\`, and \`file\`
is 1 MiB. When a client sends a chunk larger than 1 MiB (CHUNK_SIZE is
10 MiB as of #104), Rocket rejects the request body with "Data limit
reached while reading the request body" before \`data.open(...)\` in
\`upload_chunk\` has a chance to apply its own per-request cap.

Raises all three framework-level limits to CHUNK_SIZE + 1 MiB headroom
via \`rocket::Config::figment().merge(("limits", ...))\` so existing
Rocket.toml / \`ROCKET_CONFIG\` settings still compose with it.

The per-request \`(end - start).bytes()\` cap in \`upload_chunk\` remains
the authoritative limit — this change only lifts the framework floor
that was clipping legitimate chunks.
@rubenhensen
rubenhensen marked this pull request as ready for review April 24, 2026 07:19
@rubenhensen
rubenhensen merged commit 278bf76 into main Apr 24, 2026
5 checks passed
@rubenhensen
rubenhensen deleted the fix/upload-chunk-data-limit branch April 24, 2026 07:22
@github-actions github-actions Bot mentioned this pull request Apr 24, 2026
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.

When chunk size is >1mb rocket keeps throwing Data limit reached while reading the request body

1 participant