srbhr/Resume-Matcher · error · Error
Failed to parse resume data. The resume content may be corru
Error message
Failed to parse resume data. The resume content may be corrupted.
What it means
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.
Source
Thrown at apps/frontend/app/print/resumes/[id]/page.tsx:103
}
const payload = (await res.json()) as {
data: { processed_resume?: ResumeData; raw_resume?: { content?: string } };
};
if (payload.data.processed_resume) {
return payload.data.processed_resume;
}
if (payload.data.raw_resume?.content) {
try {
return JSON.parse(payload.data.raw_resume.content) as ResumeData;
} catch (error) {
// Log error for debugging instead of silently failing
// Note: Avoid logging content preview to prevent PII exposure
console.error('Failed to parse resume JSON:', {
resumeId: id,
error: error instanceof Error ? error.message : 'Unknown error',
contentLength: payload.data.raw_resume.content.length,
});
throw new Error('Failed to parse resume data. The resume content may be corrupted.');
}
}
return {} as ResumeData;
}
/**
* Parse spacing level from string, clamped to valid range 1-5
*/
function parseSpacingLevel(value: string | undefined, defaultValue: SpacingLevel): SpacingLevel {
if (!value) return defaultValue;
const num = parseInt(value, 10);
if (isNaN(num) || num < 1 || num > 5) return defaultValue;
return num as SpacingLevel;
}
/**
* Parse margin value from string, clamped to valid range 5-25
*/View on GitHub (pinned to 116f9cc3b0)
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
Example fix
// before
const data = JSON.parse(payload.data.raw_resume.content) as ResumeData;
// after
let data: ResumeData;
try {
data = JSON.parse(payload.data.raw_resume.content) as ResumeData;
} catch {
data = {} as ResumeData; // or surface a retry/reupload UI
} Defensive patterns
Strategy: try-catch
Validate before calling
function isParseableResume(content) {
if (typeof content !== 'string' || content.length === 0) return false;
try {
const parsed = JSON.parse(content);
return parsed && typeof parsed === 'object';
} catch { return false; }
} Type guard
function isResumeData(v) {
return v !== null && typeof v === 'object' &&
Array.isArray((v as ResumeData).experience ?? []);
} Try / catch
try {
const data = await fetchResumeData(id);
render(data);
} catch (e) {
if (e.message.includes('Failed to parse resume data')) {
showResumeCorruptedPage(); // offer re-upload
} else { throw e; }
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Upload failed for ${fileToUpload.file.name}. Status: ${respo
- Failed to load LLM config (status ${res.status}).
- ${message = data.detail or Failed to update LLM config (stat
- Failed to test LLM connection (status ${res.status}).
- Failed to fetch system status (status ${res.status}).
AI-assisted analysis of srbhr/Resume-Matcher@116f9cc3b0 (2026-08-28).
Data as JSON: /api/errors/7227a8d7d4a6da09.
Report an issue: GitHub.