Mitigate Vercel 413 upload failures with strict payload limits, validation, and user-facing error handling#2
Merged
Conversation
Agent-Logs-Url: https://github.com/gzhang33/imgtowebp/sessions/24659e10-c5d6-4655-9b99-3fdf0366ad5b Co-authored-by: gzhang33 <120421065+gzhang33@users.noreply.github.com>
…back Agent-Logs-Url: https://github.com/gzhang33/imgtowebp/sessions/24659e10-c5d6-4655-9b99-3fdf0366ad5b Co-authored-by: gzhang33 <120421065+gzhang33@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gzhang33/imgtowebp/sessions/24659e10-c5d6-4655-9b99-3fdf0366ad5b Co-authored-by: gzhang33 <120421065+gzhang33@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gzhang33/imgtowebp/sessions/24659e10-c5d6-4655-9b99-3fdf0366ad5b Co-authored-by: gzhang33 <120421065+gzhang33@users.noreply.github.com>
Agent-Logs-Url: https://github.com/gzhang33/imgtowebp/sessions/24659e10-c5d6-4655-9b99-3fdf0366ad5b Co-authored-by: gzhang33 <120421065+gzhang33@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
gzhang33
May 9, 2026 16:24
View session
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
This PR addresses
413 FUNCTION_PAYLOAD_TOO_LARGEon Vercel by hardening the current server-upload path to block oversize payloads early, enforce file safety constraints, and return clear UI feedback instead of opaque failures.Given the existing Flask/Vercel deployment shape, the changes focus on minimal-risk production mitigation while preserving current conversion flow.
Upload-path hard limits (server-side)
MAX_CONTENT_LENGTH = 4MBsafety margin)./uploadprocessing.Validation and safety policy
validate_upload_payload) for:.jpg/.jpeg/.png)image/jpeg,image/png)safe_subdir, path-under-root checks) intact.413 + payload-too-large UX fallback
RequestEntityTooLargehandler that redirects to upload page with concise user-facing message.Client-side preflight and state recovery
DataTransferassignment is unavailable, with explicit recovery guidance.Critical regression coverage