Add configurable max file size limit to audio endpoints (#19) - #31
Merged
ashrafee-dev merged 1 commit intoAug 13, 2026
Merged
Conversation
) - 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
|
@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. |
Owner
|
Nice work. Thank you for contributing. |
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.
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: addedMAX_FILE_SIZE(default 25 MB), overridable via theMAX_FILE_SIZEenv var so it isn't a hardcoded magic number.app/api/analyze.py:/audio: reject uploads larger thanMAX_FILE_SIZEwith HTTP413before processing (file.file.read()result is checked first)./ws: reject oversized frames with a clear{"error": "File too large..."}JSON message andcontinue, beforefiletype.guess/transcription.Acceptance criteria
/audioand/wsNote
This enforces the limit after the body is read into memory, matching the issue's primary proposal. The proxy-level /
Content-Lengthpre-check option mentioned in the issue is left to deployment config; happy to add aContent-Lengthshort-circuit if you'd prefer stronger protection.