Skip to content

feat: make the PUT /response body limit configurable - #163

Draft
Dzejkop wants to merge 1 commit into
mainfrom
dzejkop/response-body-limit
Draft

Dzejkop wants to merge 1 commit into
mainfrom
dzejkop/response-body-limit

Conversation

@Dzejkop

@Dzejkop Dzejkop commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

WIP-109 registration responses grow to 15 MiB + 4 KiB of plaintext (world-id-protocol#1246), which is about 20 MiB after sealing, AES-GCM and base64. The bridge rejects bodies over 5 MiB on every route, so such a response cannot be stored.

Changes

  • Server: RESPONSE_BODY_LIMIT_BYTES sets the body limit for PUT /response/:id only. Unset keeps 5 MiB, so merging this changes nothing until a deployment sets it. Every other route keeps the 5 MiB limit. A malformed value fails startup.
  • Client: reads replies of up to 22 MiB (was 5 MiB), so it can fetch a full-size response.
  • Metric: histogram message_bridge.response_stored_bytes records the size of each stored response.
  • message_bridge::app and server::start take the limit as a new argument.

Rollout

  • Set RESPONSE_BODY_LIMIT_BYTES=23068672 (22 MiB) on staging first. Clearing the variable and restarting restores 5 MiB.
  • Stored responses stay in Redis for the 900 s TTL. Staging Redis is a cache.t4g.micro (about 0.5 GiB), so a few dozen full-size responses fill it; check Redis memory and the new histogram before raising the limit in production.

Not changed

  • An oversized body is still answered with 400, the same status as a missing session.
  • The client's 30 s per-request timeout. A 20 MiB upload needs about 5.6 Mbit/s to finish in time, so this probably needs a follow-up for mobile.

Validation

cargo fmt --all -- --check, cargo clippy --workspace --all-targets --all-features, cargo build --workspace --locked and cargo test --workspace --all-features (70 tests, local Redis) pass. The new integration test checks that only PUT /response/:id follows the configured limit.

🤖 Generated with Claude Code

RESPONSE_BODY_LIMIT_BYTES sets the limit for PUT /response/:id only; unset keeps
5 MiB. The client reads replies of up to 22 MiB, and a histogram records the
stored response size.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant