feat: add file size validation for resume uploads (closes #135)#150
Open
singhanurag0317-bit wants to merge 2 commits into
Open
feat: add file size validation for resume uploads (closes #135)#150singhanurag0317-bit wants to merge 2 commits into
singhanurag0317-bit wants to merge 2 commits into
Conversation
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.
Description
This pull request resolves Issue #135 ("Add file size validation for resume uploads") by implementing a configurable upload size limit setting, validating the upload's size prior to loading its contents into memory, and returning descriptive HTTP 400 validation error responses to the client on limit violation.
Key Improvements
Configurable Size Limits (
MAX_UPLOAD_SIZE):MAX_UPLOAD_SIZE: int = 5 * 1024 * 1024(5 MB default) inside theSettingsclass inbackend/app/config.py.MAX_UPLOAD_SIZE.In-Memory Buffer Allocation Prevention:
apply_for_interviewinsidebackend/app/routers/application.pyto check the file size before executing theresume.read()buffer read operation.seek/tellto safely determine the file size ifresume.sizeis not directly populated by Starlette/FastAPI.BadRequestError(returning an HTTP 400 response) if the file size limit is exceeded.SQLite Database & Test Environment Corrections:
JSONBinbackend/app/models/dsa_question.pyby introducing a dialect-agnosticJSON().with_variant(JSONB, "postgresql")column mapping.dsa_questionmodel import inside the pytest setup hookcreate_tablesinbackend/tests/conftest.pyto preventNoReferencedTableErrordatabase setup failures.Integration Test Suite:
backend/tests/test_routers/test_application.pytargeting/applications/{interview_id}endpoints.Verification
pytestinside the virtual environment: