Skip to content

Add configurable max file size limit to audio endpoints (#19) - #31

Merged
ashrafee-dev merged 1 commit into
ashrafee-dev:mainfrom
ranjanssgj:feat/file-size-limit-19
Aug 13, 2026
Merged

Add configurable max file size limit to audio endpoints (#19)#31
ashrafee-dev merged 1 commit into
ashrafee-dev:mainfrom
ranjanssgj:feat/file-size-limit-19

Conversation

@ranjanssgj

Copy link
Copy Markdown
Contributor

Summary

Closes #19. Adds an upper bound on audio upload size to prevent RAM exhaustion (payload is buffered into memory and also written to /dev/shm, a RAM-backed tmpfs).

Changes

  • app/config.py: added MAX_FILE_SIZE (default 25 MB), overridable via the MAX_FILE_SIZE env var so it isn't a hardcoded magic number.
  • app/api/analyze.py:
    • /audio: reject uploads larger than MAX_FILE_SIZE with HTTP 413 before processing (file.file.read() result is checked first).
    • /ws: reject oversized frames with a clear {"error": "File too large..."} JSON message and continue, before filetype.guess/transcription.

Acceptance criteria

  • Oversized requests/messages rejected with a clear error (no silent processing or crash)
  • Limit is configurable via env var, centralized in one constant
  • Applies to both /audio and /ws

Note

This enforces the limit after the body is read into memory, matching the issue's primary proposal. The proxy-level / Content-Length pre-check option mentioned in the issue is left to deployment config; happy to add a Content-Length short-circuit if you'd prefer stronger protection.

)

- Add MAX_FILE_SIZE to config.py, overridable via MAX_FILE_SIZE env var (default 25MB)
- Reject oversized uploads on /audio with HTTP 413 before processing
- Reject oversized messages on /ws with a clear JSON error before processing
- Addresses acceptance criteria: configurable, applies to both endpoints, clear rejection
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

@ranjanssgj is attempting to deploy a commit to the ashrafee-dev's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ashrafee-dev
ashrafee-dev merged commit 18d94c9 into ashrafee-dev:main Aug 13, 2026
0 of 2 checks passed
@ashrafee-dev

Copy link
Copy Markdown
Owner

Nice work. Thank you for contributing.

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.

FileSize: Add file size limit to audio upload endpoints (/audio, /ws)

2 participants