{"record":{"id":"2e3ba49698c852b7","repo":"srbhr/Resume-Matcher","slug":"job-description-not-found","errorCode":null,"errorMessage":"Job description not found","messagePattern":"Job description not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"apps/backend/app/routers/resumes.py","lineNumber":814,"sourceCode":"\n    return ResumeListResponse(request_id=str(uuid4()), data=summaries)\n\n\n@router.post(\"/improve/preview\", response_model=ImproveResumeResponse)\nasync def improve_resume_preview_endpoint(\n    request: ImproveResumeRequest,\n) -> ImproveResumeResponse:\n    \"\"\"Preview a tailored resume without persisting it.\n\n    The response includes resume_preview data but leaves resume_id null.\n    \"\"\"\n    resume = await db.get_resume(request.resume_id)\n    if not resume:\n        raise HTTPException(status_code=404, detail=\"Resume not found\")\n\n    job = await db.get_job(request.job_id)\n    if not job:\n        raise HTTPException(status_code=404, detail=\"Job description not found\")\n\n    language = get_content_language()\n    prompt_id = request.prompt_id or _get_default_prompt_id()\n\n    stage = \"load_job_keywords\"\n    detail = \"Failed to preview resume. Please try again.\"\n    try:\n        return await asyncio.wait_for(\n            _improve_preview_flow(\n                request=request,\n                resume=resume,\n                job=job,\n                language=language,\n                prompt_id=prompt_id,\n            ),\n            timeout=settings.request_timeout_seconds,\n        )\n    except asyncio.TimeoutError:","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/routers/resumes.py#L796-L832","documentation":"improve_resume_preview_endpoint raises HTTP 404 when db.get_job(request.job_id) finds no job description. After the resume is validated, the preview needs a matching persisted job description to tailor against.","triggerScenarios":"POST to improve/preview with a job_id that was deleted, never saved, or created after the resume record (IDs from different DB sessions); job_id omitted/empty and resolved to a non-existent record.","commonSituations":"Job description deleted via the jobs UI while the resume editor stayed open; seeding scripts created resumes but not jobs; frontend cached an old job list; wrong environment's database.","solutions":["Re-create or re-save the job description and use its current job_id in the preview request","Verify the job exists (GET /jobs/{job_id}) before calling preview","Ensure the client's job_id state is refreshed after any job deletion","Check both IDs belong to the same database/environment"],"exampleFix":"// before\ncPreview(job.id) // job was deleted earlier\n// after\nif (!(await jobExists(job.id))) job = await createJob(jdText);\npreview({resume_id: resume.id, job_id: job.id})","handlingStrategy":"validation","validationCode":"async function requireJob(id: string) {\n  const res = await fetch(`/api/jobs/${id}`);\n  if (!res.ok) throw new Error('Job description missing — re-save it before tailoring');\n  return res.json();\n}\nawait requireJob(previewPayload.job_id); // before calling preview","typeGuard":"function hasJobRef(r: unknown): r is {job_id: string} {\n  return typeof r === 'object' && r !== null &&\n    typeof (r as any).job_id === 'string' && (r as any).job_id.length > 0;\n}","tryCatchPattern":"try {\n  await api.improvePreview({resume_id, job_id});\n} catch (e) {\n  if (e.response?.status === 404 && /job description/i.test(e.response.data?.detail ?? '')) {\n    openJobEditorToResave();\n  } else throw e;\n}","preventionTips":["Verify the job description exists before previewing","Refresh the client's job list after deletions; disable preview when the referenced job is gone","Create the job description in the same session/DB as the resume before tailoring","Guard seeding scripts so resumes are never created without their jobs"],"tags":["http-404","resource-not-found","database","job-description"],"backgroundTag":"resource-not-found-404","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}