srbhr/Resume-Matcher · error · HTTPException
File too large. Maximum size: {MAX_FILE_SIZE // (1024 * 1024
Error message
File too large. Maximum size: {MAX_FILE_SIZE // (1024 * 1024)}MB What it means
After reading the upload into memory, upload_resume compares the byte length against MAX_FILE_SIZE and rejects oversized files with HTTP 413 (Payload Too Large). The detail embeds the configured limit in MB via MAX_FILE_SIZE // (1024 * 1024).
Source
Thrown at apps/backend/app/routers/resumes.py:647
@router.post("/upload", response_model=ResumeUploadResponse)
async def upload_resume(file: UploadFile = File(...)) -> ResumeUploadResponse:
"""Upload and process a resume file (PDF/DOCX).
Converts the file to Markdown and stores it in the database.
Optionally parses to structured JSON if LLM is configured.
"""
# Validate file type
if file.content_type not in ALLOWED_TYPES:
raise HTTPException(
status_code=400,
detail=f"Invalid file type: {file.content_type}. Allowed: PDF, DOC, DOCX",
)
# Read and validate size
content = await file.read()
if len(content) > MAX_FILE_SIZE:
raise HTTPException(
status_code=413,
detail=f"File too large. Maximum size: {MAX_FILE_SIZE // (1024 * 1024)}MB",
)
if len(content) == 0:
raise HTTPException(status_code=400, detail="Empty file")
# Convert to markdown
try:
markdown_content = await parse_document(content, file.filename or "resume.pdf")
except Exception as e:
logger.error(f"Document parsing failed: {e}")
raise HTTPException(
status_code=422,
detail="Failed to parse document. Please ensure it's a valid PDF or DOCX file.",
)
# Validate extracted text is not empty (image-based PDFs / scanned documents)View on GitHub (pinned to 116f9cc3b0)
Solutions
- Upload a smaller version of the document (compress images / re-export the PDF)
- If legitimate, raise MAX_FILE_SIZE in app config and restart the backend
- Also raise the reverse proxy body limit (e.g. nginx client_max_body_size) if one sits in front
Example fix
// before: default limit rejects a 12MB scan MAX_FILE_SIZE = 10 * 1024 * 1024 # 10MB // after: raised for scanned resumes (in the app's config/settings) MAX_FILE_SIZE = 25 * 1024 * 1024 # 25MB
Defensive patterns
Strategy: validation
Validate before calling
const MAX_BYTES = 10 * 1024 * 1024; // keep in sync with backend MAX_FILE_SIZE
if (file.size > MAX_BYTES) {
throw new Error(`File is ${(file.size / 1048576).toFixed(1)}MB; limit is ${MAX_BYTES / 1048576}MB`);
} Try / catch
try {
await api.postForm('/resumes/upload', form);
} catch (e) {
if (e.response?.status === 413) {
showToast('File exceeds the size limit — compress or re-export the document');
}
} Prevention
- Check file.size client-side before uploading
- Downscale images / lower scan DPI before exporting PDFs
- Keep the frontend MAX_BYTES constant in sync with backend MAX_FILE_SIZE
- If behind a proxy, align its body-size limit with MAX_FILE_SIZE
When it happens
Trigger: POST /api/v1/resumes/upload with a file larger than MAX_FILE_SIZE bytes — e.g. multi-MB scanned PDFs, resumes with embedded high-resolution images, or portfolios with graphics-heavy DOCX files.
Common situations: Scanned/image-based PDFs at 300+ DPI; resumes exported with embedded photos or logos; raising MAX_FILE_SIZE in config without restarting; proxies (nginx client_max_body_size) also blocking before FastAPI sees the request.
Related errors
- Invalid file type: {file.content_type}. Allowed: PDF, DOC, D
- Empty file
- ${message = data.detail or Failed to update LLM config (stat
- ${data.detail || Failed to update feature config (status ${r
- ${data.detail || Failed to update language config (status ${
AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28).
Data as JSON: /api/errors/17ed189463016ebf.
Report an issue: GitHub.