{"record":{"id":"10199bacffa5f388","repo":"srbhr/Resume-Matcher","slug":"the-associated-job-description-was-not-found","errorCode":null,"errorMessage":"The associated job description was not found.","messagePattern":"The associated job description was not found\\.","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"apps/backend/app/routers/resumes.py","lineNumber":1804,"sourceCode":"        raise HTTPException(\n            status_code=400,\n            detail=\"Cover letter can only be generated for tailored resumes. \"\n            \"Please tailor this resume to a job description first.\",\n        )\n\n    # Get improvement record to find the job_id\n    improvement = await db.get_improvement_by_tailored_resume(resume_id)\n    if not improvement:\n        raise HTTPException(\n            status_code=400,\n            detail=\"No job context found for this resume. \"\n            \"The resume may have been created before job tracking was implemented.\",\n        )\n\n    # Get the job description\n    job = await db.get_job(improvement[\"job_id\"])\n    if not job:\n        raise HTTPException(\n            status_code=404,\n            detail=\"The associated job description was not found.\",\n        )\n\n    # Get resume data\n    resume_data = resume.get(\"processed_data\")\n    if not resume_data:\n        raise HTTPException(\n            status_code=400,\n            detail=\"Resume has no processed data. Please re-upload the resume.\",\n        )\n\n    # Get language setting\n    language = get_content_language()\n\n    # Generate cover letter\n    try:\n        cover_letter_content = await generate_cover_letter(","sourceCodeStart":1786,"sourceCodeEnd":1822,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/backend/app/routers/resumes.py#L1786-L1822","documentation":"HTTP 404 raised by generate_cover_letter_endpoint when the improvement record exists and yields a job_id, but db.get_job(job_id) returns nothing — the job description that the resume was tailored against has been deleted or is otherwise missing. The AI prompt needs the job text, so generation is refused.","triggerScenarios":"Cover-letter generation for a tailored resume whose linked job was deleted (user removed the job, cascade delete didn't remove improvements, or job lives in another environment's DB).","commonSituations":"User deleted the job posting but kept the tailored resume, then tries to generate a cover letter; job import/sync pipeline removed the job; cross-environment ID reuse (improvement's job_id not present in current DB).","solutions":["Re-create or re-import the missing job description, then re-tailor the resume so the improvement links to a valid job.","Delete orphaned tailored resumes/improvements and re-tailor against an existing job.","Restore the job record from backup if it was deleted accidentally.","Add a cascade/consistency rule: deleting a job should archive or flag dependent tailored resumes."],"exampleFix":"// before\nawait api.post(`/resumes/${resumeId}/generate-cover-letter`); // 404: job deleted\n\n// after\nconst resume = await api.get(`/resumes/${resumeId}`);\nconst job = await api.get(`/jobs/${resume.data.jobId}`).catch(() => null);\nif (!job) {\n  const re = await api.post(`/resumes/${resume.data.parentId}/tailor`, { jobId: existingJobId });\n  resumeId = re.data.id;\n}\nawait api.post(`/resumes/${resumeId}/generate-cover-letter`);","handlingStrategy":"fallback","validationCode":"const improvement = await api.get(`/improvements?tailoredResumeId=${resumeId}`);\nconst job = improvement.data.length\n  ? await api.get(`/jobs/${improvement.data[0].job_id}`).catch(() => null)\n  : null;\nif (!job) throw new Error('Linked job missing — re-tailor against an existing job.');","typeGuard":"const jobStillExists = (improvement, job) => Boolean(improvement?.job_id) && job != null && job.id === improvement.job_id;","tryCatchPattern":"try {\n  await api.post(`/resumes/${resumeId}/generate-cover-letter`);\n} catch (e) {\n  if (e.response?.status === 404 && /job description/.test(e.response.data?.detail ?? '')) {\n    notify('The job was deleted. Pick a job to re-tailor against.');\n    openJobPicker(resumeId);\n  } else throw e;\n}","preventionTips":["Warn users before deleting a job that has tailored resumes depending on it.","Periodically check improvements.job_id references resolve to existing jobs.","Offer an in-flow 're-tailor' fallback when the linked job is gone."],"tags":["http-404","not-found","referential-integrity"],"backgroundTag":"referenced-resource-deleted","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}