{"record":{"id":"17ed189463016ebf","repo":"srbhr/Resume-Matcher","slug":"file-too-large-maximum-size-max-file-size-1","errorCode":null,"errorMessage":"File too large. Maximum size: {MAX_FILE_SIZE // (1024 * 1024)}MB","messagePattern":"File too large\\. Maximum size: (.+?)MB","errorType":"http","errorClass":"HTTPException","httpStatus":413,"severity":"error","filePath":"apps/backend/app/routers/resumes.py","lineNumber":647,"sourceCode":"\n@router.post(\"/upload\", response_model=ResumeUploadResponse)\nasync def upload_resume(file: UploadFile = File(...)) -> ResumeUploadResponse:\n    \"\"\"Upload and process a resume file (PDF/DOCX).\n\n    Converts the file to Markdown and stores it in the database.\n    Optionally parses to structured JSON if LLM is configured.\n    \"\"\"\n    # Validate file type\n    if file.content_type not in ALLOWED_TYPES:\n        raise HTTPException(\n            status_code=400,\n            detail=f\"Invalid file type: {file.content_type}. Allowed: PDF, DOC, DOCX\",\n        )\n\n    # Read and validate size\n    content = await file.read()\n    if len(content) > MAX_FILE_SIZE:\n        raise HTTPException(\n            status_code=413,\n            detail=f\"File too large. Maximum size: {MAX_FILE_SIZE // (1024 * 1024)}MB\",\n        )\n\n    if len(content) == 0:\n        raise HTTPException(status_code=400, detail=\"Empty file\")\n\n    # Convert to markdown\n    try:\n        markdown_content = await parse_document(content, file.filename or \"resume.pdf\")\n    except Exception as e:\n        logger.error(f\"Document parsing failed: {e}\")\n        raise HTTPException(\n            status_code=422,\n            detail=\"Failed to parse document. Please ensure it's a valid PDF or DOCX file.\",\n        )\n\n    # Validate extracted text is not empty (image-based PDFs / scanned documents)","sourceCodeStart":629,"sourceCodeEnd":665,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/routers/resumes.py#L629-L665","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: default limit rejects a 12MB scan\nMAX_FILE_SIZE = 10 * 1024 * 1024  # 10MB\n// after: raised for scanned resumes (in the app's config/settings)\nMAX_FILE_SIZE = 25 * 1024 * 1024  # 25MB","handlingStrategy":"validation","validationCode":"const MAX_BYTES = 10 * 1024 * 1024; // keep in sync with backend MAX_FILE_SIZE\nif (file.size > MAX_BYTES) {\n  throw new Error(`File is ${(file.size / 1048576).toFixed(1)}MB; limit is ${MAX_BYTES / 1048576}MB`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await api.postForm('/resumes/upload', form);\n} catch (e) {\n  if (e.response?.status === 413) {\n    showToast('File exceeds the size limit — compress or re-export the document');\n  }\n}","preventionTips":["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"],"tags":["http-413","file-upload","file-size","validation"],"backgroundTag":"file-too-large","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}