{"record":{"id":"bdfc9c29d5b74569","repo":"srbhr/Resume-Matcher","slug":"no-job-descriptions-provided","errorCode":null,"errorMessage":"No job descriptions provided","messagePattern":"No job descriptions provided","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"apps/backend/app/routers/jobs.py","lineNumber":19,"sourceCode":"\"\"\"Job description management endpoints.\"\"\"\n\nfrom fastapi import APIRouter, HTTPException\n\nfrom app.database import db\nfrom app.schemas import JobUploadRequest, JobUploadResponse\n\nrouter = APIRouter(prefix=\"/jobs\", tags=[\"Jobs\"])\n\n\n@router.post(\"/upload\", response_model=JobUploadResponse)\nasync def upload_job_descriptions(request: JobUploadRequest) -> JobUploadResponse:\n    \"\"\"Upload one or more job descriptions.\n\n    Stores the raw text for later use in resume tailoring.\n    Returns an array of job_ids corresponding to the input array.\n    \"\"\"\n    if not request.job_descriptions:\n        raise HTTPException(status_code=400, detail=\"No job descriptions provided\")\n\n    job_ids = []\n    for jd in request.job_descriptions:\n        if not jd.strip():\n            raise HTTPException(status_code=400, detail=\"Empty job description\")\n\n        job = await db.create_job(\n            content=jd.strip(),\n            resume_id=request.resume_id,\n        )\n        job_ids.append(job[\"job_id\"])\n\n    return JobUploadResponse(\n        message=\"data successfully processed\",\n        job_id=job_ids,\n        request={\n            \"job_descriptions\": request.job_descriptions,\n            \"resume_id\": request.resume_id,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/routers/jobs.py#L1-L37","documentation":"A 400 Bad Request from upload_job_descriptions when the request body's job_descriptions field is missing, null, or an empty array. The endpoint requires at least one job description string to store for later resume tailoring.","triggerScenarios":"POSTing a JobUploadRequest with job_descriptions omitted, set to null, or set to []; sending a body that fails to include the field the client-side serializer dropped (e.g. empty arrays stripped).","commonSituations":"Client builds the payload from a textarea split that yields an empty list after filtering; a form submitted without pasting any job text; API consumers testing the endpoint with {} as the body.","solutions":["Include at least one non-empty string in the job_descriptions array before calling the endpoint","Fix client-side splitting/filtering so blank text isn't reduced to an empty array","Return a clear client-side validation error before sending the request"],"exampleFix":"// before\nawait api.post('/jobs/upload', { job_descriptions: texts.filter(Boolean) });\n// after: guard client-side\nconst cleaned = texts.map(t => t.trim()).filter(Boolean);\nif (cleaned.length === 0) throw new ValidationError('At least one job description is required');\nawait api.post('/jobs/upload', { job_descriptions: cleaned, resume_id });","handlingStrategy":"validation","validationCode":"function validateJobUpload(body) {\n  const jds = (body.job_descriptions ?? []).map(s => String(s).trim()).filter(Boolean);\n  if (jds.length === 0) throw new ValidationError('job_descriptions must contain at least one non-empty string');\n  return { ...body, job_descriptions: jds };\n}","typeGuard":"function hasJobDescriptions(b) {\n  return Array.isArray(b?.job_descriptions) && b.job_descriptions.length > 0;\n}","tryCatchPattern":"try {\n  await api.post('/jobs/upload', body);\n} catch (e) {\n  if (e.response?.status === 400 && e.response.data?.detail === 'No job descriptions provided') {\n    showFormError('Please paste at least one job description.');\n  } else throw e;\n}","preventionTips":["Validate the form field is non-empty before submit","Don't strip empty arrays from the serialized request body","Split pasted multi-job text and check at least one segment survives filtering","Mirror backend validation client-side for fast feedback"],"tags":["http","validation","bad-request","fastapi"],"backgroundTag":"missing-request-body-field","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}