{"record":{"id":"2634cba7555e95c3","repo":"srbhr/Resume-Matcher","slug":"failed-to-load-resume-status-res-status","errorCode":null,"errorMessage":"Failed to load resume (status ${res.status}).","messagePattern":"Failed to load resume \\(status (.+?)\\)\\.","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/frontend/lib/api/resume.ts","lineNumber":196,"sourceCode":"  return postImprove('/resumes/improve/preview', {\n    resume_id: resumeId,\n    job_id: jobId,\n    prompt_id: promptId ?? null,\n  });\n}\n\n/** Confirms and saves a tailored resume */\nexport async function confirmImproveResume(\n  payload: ImproveResumeConfirmRequest\n): Promise<ImprovedResult> {\n  return postImprove('/resumes/improve/confirm', payload as unknown as Record<string, unknown>);\n}\n\n/** Fetches a raw resume record for previewing the original upload */\nexport async function fetchResume(resumeId: string): Promise<ResumeResponse['data']> {\n  const res = await apiFetch(`/resumes?resume_id=${encodeURIComponent(resumeId)}`);\n  if (!res.ok) {\n    throw new Error(`Failed to load resume (status ${res.status}).`);\n  }\n  const payload = (await res.json()) as ResumeResponse;\n  // Support both raw_resume content (initial) and processed_resume (if available)\n  // The viewer/builder logic should prioritize processed data if present\n  return payload.data;\n}\n\nexport async function fetchResumeList(includeMaster = false): Promise<ResumeListItem[]> {\n  const res = await apiFetch(`/resumes/list?include_master=${includeMaster ? 'true' : 'false'}`);\n  if (!res.ok) {\n    throw new Error(`Failed to load resumes list (status ${res.status}).`);\n  }\n  const payload = (await res.json()) as { data: ResumeListItem[] };\n  return payload.data;\n}\n\nexport async function updateResume(\n  resumeId: string,","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/frontend/lib/api/resume.ts#L178-L214","documentation":"fetchResume retrieves a single raw resume record for previewing the original upload via GET /resumes?resume_id=... When the backend responds with a non-2xx status, the client discards any body and throws this Error with the HTTP status code embedded. It signals that the resume could not be loaded from the API, not a client-side data problem.","triggerScenarios":"apiFetch(`/resumes?resume_id=${encodeURIComponent(resumeId)}`) returns res.ok === false: the resumeId does not exist (404), the request is unauthenticated/forbidden (401/403), the backend /resumes GET route is down or returns 500, or the id was malformed so the server rejects it (400).","commonSituations":"Previewing an uploaded resume after the record was deleted (e.g. by another tab or a re-upload flow); stale IDs cached in UI state after a database reset; dev server proxy not pointing at the API so requests 404; expired auth session returning 401.","solutions":["Log/inspect the status in the thrown message and verify the resumeId exists via GET /resumes/list before calling fetchResume.","Check authentication: ensure the session/token is valid and apiFetch attaches credentials; re-authenticate on 401.","Confirm the frontend API base URL/proxy targets the running backend (404 often means wrong base path or backend not started).","Add graceful UI handling: catch the error and show a 'resume not found / unavailable' state instead of crashing the preview."],"exampleFix":"// before\nconst resume = await fetchResume(resumeId);\n\n// after\nlet resume;\ntry {\n  resume = await fetchResume(resumeId);\n} catch (e) {\n  console.error('Resume load failed:', (e as Error).message);\n  showUnavailableState();\n}","handlingStrategy":"try-catch","validationCode":"const list = await fetchResumeList(false);\nif (!list.some((r) => r.id === resumeId)) {\n  console.warn('Skipping fetchResume: unknown resumeId', resumeId);\n}","typeGuard":"function isResumeData(x: unknown): x is ResumeResponse['data'] {\n  return typeof x === 'object' && x !== null && 'id' in x;\n}","tryCatchPattern":"try {\n  const resume = await fetchResume(resumeId);\n} catch (e) {\n  if ((e as Error).message.includes('status 404')) {\n    showNotFoundState();\n  } else {\n    showGenericError(e);\n  }\n}","preventionTips":["Validate the resumeId against fetchResumeList before previewing.","Handle 401 centrally (apiFetch interceptor) so expired sessions refresh tokens before requests.","Render a friendly empty/error state instead of letting the promise rejection bubble to the console.","Keep frontend API base URL/proxy config in one shared module to avoid 404s from drift."],"tags":["http-status","api-client","frontend","resume"],"backgroundTag":"http-error-response","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}