nginx lets through the uploads the backend accepts: no limit was set, so its 1 MB default refused them all (#1057) #1058

Merged
claude-bot merged 2 commits from fix/1057-nginx-upload-limit into main 2026-10-04 00:58:24 +00:00
Collaborator

Closes #1057.

Summary

nginx.conf set no client_max_body_size, so nginx's default of 1 MB applied to everything proxied to the backend. Confirmed on dev (v4.5.0-rc2): a 2 MB POST to /api/campaigns/import gets nginx's 413 and never reaches the app, while a 0.5 MB one does. That refused every map image (the backend allows 75 MB), handout file and page picture (8 MB), and campaign import (100 MB) in a deployed build. The v4.4.1 tag's nginx.conf has none either, so production behaves the same.

  • The fix. location /api/ sets client_max_body_size 110m, just above the largest upload the backend accepts. The backend keeps the per-kind limits and their worded messages.
  • The guard. A new test, tests/test_nginx_upload_limit.py, reads nginx.conf and fails if the proxy's limit is missing or falls below the backend's largest (media_max_upload_bytes, map_max_upload_bytes, and the import's cap). Nothing caught this before: the backend suite calls the app directly, and the journeys upload small files.

#991 part 2 will give the import route its own location, with the backend's admin-settable limit as the only one.

Changelog

  • changelog.d/1057-nginx-upload-limit.fixed.md

Test plan

  • The new test: 2 passed (on docker-test, in the backend image).
  • nginx -t on the edited config in nginx:1.31-alpine: syntax ok, test successful.
  • ruff 0.4.4 format and check on the new file: clean.
  • CI on this PR.
  • Not yet seen in a running build: a real upload over 1 MB going through. That needs the image this PR builds; it is the first thing to check on dev after the next prerelease.

🤖 Generated with Claude Code

Closes #1057. ## Summary `nginx.conf` set no `client_max_body_size`, so nginx's default of 1 MB applied to everything proxied to the backend. Confirmed on dev (`v4.5.0-rc2`): a 2 MB POST to `/api/campaigns/import` gets nginx's 413 and never reaches the app, while a 0.5 MB one does. That refused every map image (the backend allows 75 MB), handout file and page picture (8 MB), and campaign import (100 MB) in a deployed build. The `v4.4.1` tag's `nginx.conf` has none either, so production behaves the same. - **The fix.** `location /api/` sets `client_max_body_size 110m`, just above the largest upload the backend accepts. The backend keeps the per-kind limits and their worded messages. - **The guard.** A new test, `tests/test_nginx_upload_limit.py`, reads `nginx.conf` and fails if the proxy's limit is missing or falls below the backend's largest (`media_max_upload_bytes`, `map_max_upload_bytes`, and the import's cap). Nothing caught this before: the backend suite calls the app directly, and the journeys upload small files. #991 part 2 will give the import route its own location, with the backend's admin-settable limit as the only one. ## Changelog - [x] `changelog.d/1057-nginx-upload-limit.fixed.md` ## Test plan - [x] The new test: 2 passed (on docker-test, in the backend image). - [x] `nginx -t` on the edited config in `nginx:1.31-alpine`: syntax ok, test successful. - [x] ruff 0.4.4 format and check on the new file: clean. - [ ] CI on this PR. - [ ] Not yet seen in a running build: a real upload over 1 MB going through. That needs the image this PR builds; it is the first thing to check on dev after the next prerelease. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ruff format the nginx limit test (#1057)
All checks were successful
CI / Summarisation accuracy eval harness (stub provider) (pull_request) Successful in 1m23s
CI / Backend lint (ruff) (pull_request) Successful in 36s
CI / Bot/backend version sync (pull_request) Successful in 39s
CI / Feedback site tests (pull_request) Successful in 1m3s
CI / Bot tests and audit (pull_request) Successful in 2m38s
CI / Does this change touch the recording path? (pull_request) Successful in 30s
CI / Synthetic session harness (no GPU, no LLM) (pull_request) Has been skipped
CI / Docker image build (pull_request) Successful in 2m59s
CI / Frontend (shard 2/2) (pull_request) Successful in 10m54s
CI / Frontend (shard 1/2) (pull_request) Successful in 19m41s
CI / End-to-end journeys (phone) (pull_request) Successful in 15m0s
CI / End-to-end journeys (keyboard) (pull_request) Successful in 15m22s
CI / End-to-end journeys (desktop) (pull_request) Successful in 16m41s
CI / Backend migration, tests, and audit (pull_request) Successful in 50m42s
a0837dc04c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude-bot deleted branch fix/1057-nginx-upload-limit 2026-10-04 00:58:26 +00:00
rbrooks referenced this pull request from a commit 2026-10-04 06:57:14 +00:00
Sign in to join this conversation.
No description provided.