Skip to content

Fix file size limit inconsistency: frontend allows 50MB but backend enforces 25MB #10

Description

@emares17

Summary

The frontend client-side validation allows files up to 50MB, but the server enforces a hard 25MB ceiling. Users with files between 25–50MB get no warning on the frontend but receive a server error on submit.

Root Cause

Three misaligned values:

  • app.py:12MAX_CONTENT_LENGTH = 25 * 1024 * 1024 (Flask hard limit, request is rejected before reaching any route handler)
  • backend/routes/uploads.py/upload and /preview both hardcode if file_size_mb > 25:
  • frontend-vite/react-ts/src/components/labelUploader.tsx — both handleUpload and handlePreview use const maxSize = 50 * 1024 * 1024

The settings.py config has MAX_FILE_SIZE = 50MB (dev) / 25MB (prod), but the route handlers ignore this config and hardcode 25MB directly.

Impact

Users who select a file between 25–50MB will pass client-side validation but get a 413 error from the server with no clear explanation.

Fix Options

  1. Align frontend down to 25MB — matches the current server reality, no backend changes needed
  2. Raise the limit to 50MB everywhere — update MAX_CONTENT_LENGTH in app.py, both route handlers in uploads.py, and ProductionConfig.MAX_FILE_SIZE in settings.py

Option 2 requires verifying the hosting tier supports 50MB request bodies before proceeding.

Notes

  • This inconsistency pre-dates the label preview feature (PR Add label preview before full generation #9) — /upload had the hardcoded 25MB check before preview was added
  • The route-level file_size_mb > 25 checks are redundant given MAX_CONTENT_LENGTH, but serve as a friendlier error message

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions