{"record":{"id":"e6ae7d6b37698f56","repo":"srbhr/Resume-Matcher","slug":"failed-to-fetch-job-description-status-res-stat","errorCode":null,"errorMessage":"Failed to fetch job description (status ${res.status}): ${text}","messagePattern":"Failed to fetch job description \\(status (.+?)\\): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/frontend/lib/api/resume.ts","lineNumber":392,"sourceCode":"\n/** Retries AI processing for a failed resume */\nexport async function retryProcessing(resumeId: string): Promise<ResumeUploadResponse> {\n  const res = await apiPost(`/resumes/${encodeURIComponent(resumeId)}/retry-processing`, {});\n  if (!res.ok) {\n    const text = await res.text().catch(() => '');\n    throw new Error(`Failed to retry processing (status ${res.status}): ${text}`);\n  }\n  return res.json();\n}\n\n/** Fetches the job description used to tailor a resume */\nexport async function fetchJobDescription(\n  resumeId: string\n): Promise<{ job_id: string; content: string }> {\n  const res = await apiFetch(`/resumes/${encodeURIComponent(resumeId)}/job-description`);\n  if (!res.ok) {\n    const text = await res.text().catch(() => '');\n    throw new Error(`Failed to fetch job description (status ${res.status}): ${text}`);\n  }\n  return res.json();\n}\n","sourceCodeStart":374,"sourceCodeEnd":396,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/frontend/lib/api/resume.ts#L374-L396","documentation":"fetchJobDescription issues GET /resumes/{id}/job-description and throws this Error on any non-OK status, embedding the response body text. It converts an HTTP failure retrieving the stored job description into an exception for the caller.","triggerScenarios":"Non-2xx from the job-description endpoint: resume not found (404), no job description was ever attached to the resume (404/400), auth expired (401), or backend storage/DB read failure (500).","commonSituations":"Developers hit this when viewing a tailored resume whose original job description was not saved or was purged, when the resumeId comes from a stale link, or after the session cookie/JWT expired.","solutions":["Check the status: 404 usually means no job description exists for that resume","Verify the resume was created through the tailoring flow that stores the job description","Re-authenticate for 401/403","Check backend storage/DB health for 500 responses","Handle the null/absent case in the UI instead of assuming a description always exists"],"exampleFix":"// before\nconst jd = await fetchJobDescription(resumeId);\n// after\ntry {\n  const jd = await fetchJobDescription(resumeId);\n} catch (e) {\n  setJdError('No job description available for this resume.');\n}","handlingStrategy":"try-catch","validationCode":"if (!resumeId) throw new Error('resumeId is required');\n// Optional readiness check\nconst exists = await resumeExists(resumeId);\nif (!exists) throw new Error(`Resume ${resumeId} not found; cannot fetch job description`);","typeGuard":"function hasJobDescription(v: unknown): v is { job_id: string; content: string } {\n  return (\n    typeof v === 'object' && v !== null &&\n    typeof (v as { job_id?: unknown }).job_id === 'string' &&\n    typeof (v as { content?: unknown }).content === 'string' &&\n    (v as { content: string }).content.length > 0\n  );\n}","tryCatchPattern":"try {\n  const jd = await fetchJobDescription(resumeId);\n  setJobDescription(jd.content);\n} catch (e) {\n  if (e instanceof Error && /status 404/.test(e.message)) {\n    setJobDescription(null); // no description stored; render empty state\n  } else {\n    showError('Could not load the job description.');\n  }\n}","preventionTips":["Treat a missing job description (404) as an expected empty state, not a crash","Re-authenticate before retrying after 401","Validate resumeId origin (never use stale/hardcoded ids)","Keep resume records and their stored job descriptions in sync on deletion","Log the full error message server-side for diagnosis"],"tags":["http-error","api","fetch","frontend"],"backgroundTag":"http-non-2xx-response","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}