Skip to content

Cap import payload size and guard UI import input#1014

Open
jnunemaker wants to merge 1 commit into
mainfrom
import-size-limit
Open

Cap import payload size and guard UI import input#1014
jnunemaker wants to merge 1 commit into
mainfrom
import-size-limit

Conversation

@jnunemaker

Copy link
Copy Markdown
Collaborator

Both the API (/import) and UI (/settings/import) import endpoints read the entire request body/upload into memory before parsing, and the UI path assumed params['file'] was always an upload hash (a missing/plain-string file raised a NoMethodError → 500). This adds a 50 MB cap (Flipper::Exporters::Json::Export::MAX_BYTES) enforced before buffering — comfortably above the ~20 MB a legitimate 100k-gate export produces — so oversized payloads are rejected early via the existing import_invalid (API) / error redirect (UI) paths. The UI action now also guards a missing/non-upload file param and rescues invalid JSON, redirecting back to settings with a friendly error instead of raising. New specs cover the too-large, missing-file, and invalid-file cases for both endpoints.

🤖 Generated with Claude Code

Both the API and UI import endpoints read the entire request body/upload
into memory before parsing. Add a 50 MB cap (Export::MAX_BYTES) enforced
before buffering so oversized payloads are rejected early — well above the
~20 MB a legitimate 100k-gate export produces. The UI action also now
guards a missing/non-upload `file` param (previously a 500 NoMethodError)
and rescues invalid JSON, redirecting to settings with a friendly error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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