{"record":{"id":"7227a8d7d4a6da09","repo":"srbhr/Resume-Matcher","slug":"failed-to-parse-resume-data-the-resume-content-ma","errorCode":null,"errorMessage":"Failed to parse resume data. The resume content may be corrupted.","messagePattern":"Failed to parse resume data\\. The resume content may be corrupted\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/frontend/app/print/resumes/[id]/page.tsx","lineNumber":103,"sourceCode":"  }\n  const payload = (await res.json()) as {\n    data: { processed_resume?: ResumeData; raw_resume?: { content?: string } };\n  };\n  if (payload.data.processed_resume) {\n    return payload.data.processed_resume;\n  }\n  if (payload.data.raw_resume?.content) {\n    try {\n      return JSON.parse(payload.data.raw_resume.content) as ResumeData;\n    } catch (error) {\n      // Log error for debugging instead of silently failing\n      // Note: Avoid logging content preview to prevent PII exposure\n      console.error('Failed to parse resume JSON:', {\n        resumeId: id,\n        error: error instanceof Error ? error.message : 'Unknown error',\n        contentLength: payload.data.raw_resume.content.length,\n      });\n      throw new Error('Failed to parse resume data. The resume content may be corrupted.');\n    }\n  }\n  return {} as ResumeData;\n}\n\n/**\n * Parse spacing level from string, clamped to valid range 1-5\n */\nfunction parseSpacingLevel(value: string | undefined, defaultValue: SpacingLevel): SpacingLevel {\n  if (!value) return defaultValue;\n  const num = parseInt(value, 10);\n  if (isNaN(num) || num < 1 || num > 5) return defaultValue;\n  return num as SpacingLevel;\n}\n\n/**\n * Parse margin value from string, clamped to valid range 5-25\n */","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/srbhr/Resume-Matcher/blob/116f9cc3b00e1ac91734a6c2679bf41ea64a0edc/apps/frontend/app/print/resumes/[id]/page.tsx#L85-L121","documentation":"fetchResumeData in the print page fetches a resume payload from the API and JSON.parses raw_resume.content into a ResumeData object. When parsing fails (invalid or corrupted JSON stored in the resume content field), it logs metadata only (avoiding PII exposure) and throws this error so the print view can render a failure state.","triggerScenarios":"JSON.parse throws on payload.data.raw_resume.content — e.g. the stored content is truncated, empty string, HTML from a failed processing job, or was double-encoded/otherwise not valid JSON at upload time.","commonSituations":"Resume processing pipeline partially failed and wrote raw text instead of JSON; DB row manually edited or migrated; old resume versions stored under a different serialization format; content clipped by a column size limit.","solutions":["Re-upload or reprocess the resume so raw_resume.content is regenerated as valid JSON","Check the resume row's raw_resume.content directly (DB or API response) and validate it with JSON.parse / json.loads","Inspect the server log line 'Failed to parse resume JSON:' for the underlying parse error message and contentLength","Wrap rendering in an error boundary so users see a friendly message instead of a crash"],"exampleFix":"// before\nconst data = JSON.parse(payload.data.raw_resume.content) as ResumeData;\n// after\nlet data: ResumeData;\ntry {\n  data = JSON.parse(payload.data.raw_resume.content) as ResumeData;\n} catch {\n  data = {} as ResumeData; // or surface a retry/reupload UI\n}","handlingStrategy":"try-catch","validationCode":"function isParseableResume(content) {\n  if (typeof content !== 'string' || content.length === 0) return false;\n  try {\n    const parsed = JSON.parse(content);\n    return parsed && typeof parsed === 'object';\n  } catch { return false; }\n}","typeGuard":"function isResumeData(v) {\n  return v !== null && typeof v === 'object' &&\n    Array.isArray((v as ResumeData).experience ?? []);\n}","tryCatchPattern":"try {\n  const data = await fetchResumeData(id);\n  render(data);\n} catch (e) {\n  if (e.message.includes('Failed to parse resume data')) {\n    showResumeCorruptedPage(); // offer re-upload\n  } else { throw e; }\n}","preventionTips":["Validate raw_resume.content with JSON.parse before storing or rendering","Return structured error responses from the API instead of raw content","Add a post-upload processing check that rejects non-JSON resume content","Render the print page inside an error boundary"],"tags":["json-parse","frontend","resume-data"],"backgroundTag":"json-parse-failed","analyzedSha":"116f9cc3b00e1ac91734a6c2679bf41ea64a0edc","analyzedAt":"2026-08-28T22:51:40.999Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}