Cap import payload size and guard UI import input#1014
Open
jnunemaker wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Both the API (
/import) and UI (/settings/import) import endpoints read the entire request body/upload into memory before parsing, and the UI path assumedparams['file']was always an upload hash (a missing/plain-string file raised aNoMethodError→ 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 existingimport_invalid(API) / error redirect (UI) paths. The UI action now also guards a missing/non-uploadfileparam 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