amruthpillai/reactive-resume · error · Error
An unknown error occurred while validating the merged resume
Error message
An unknown error occurred while validating the merged resume data.
What it means
Generic catch-all in sanitizeAndParseResumeJson: any error during jsonrepair, JSON.parse, mergeDefaults, coerceValueAgainstTemplate, normalizeResumeDataForSchema, or resumeDataSchema.parse that is NOT a ZodError is re-thrown as a plain Error with this message. ZodErrors are re-thrown unchanged (with console.error logging the flattened issue); everything else (broken jsonrepair, thrown primitives, unexpected exceptions in coercers) gets wrapped here after being logged to console as 'Unknown error during resume data validation'.
Source
Thrown at packages/ai/src/resume/sanitize.ts:264
const coercedData = coerceValueAgainstTemplate(mergedData, defaultResumeData, "", diagnostics);
const normalizedData = normalizeResumeDataForSchema(coercedData as Record<string, unknown>, diagnostics);
const data = resumeDataSchema.parse({
...normalizedData,
customSections: [],
picture: defaultResumeData.picture,
metadata: defaultResumeData.metadata,
});
return { data, diagnostics };
} catch (error: unknown) {
if (error instanceof ZodError) {
console.error("Zod validation failed during resume parsing:", flattenError(error));
throw error;
}
console.error("Unknown error during resume data validation:", error);
throw new Error("An unknown error occurred while validating the merged resume data.");
}
}
View on GitHub (pinned to 3a5b12e2a4)
Solutions
- Inspect server logs: the original error is logged via console.error('Unknown error during resume data validation:', error) immediately before the rethrow — read that line for the real cause.
- If it is jsonrepair failing, pre-trim the model output to the outermost {...} before calling sanitizeAndParseResumeJson, or increase the model's max_tokens so output isn't truncated.
- If a coercer threw, reproduce with the exact resultText and step through mergeDefaults/coerceValueAgainstTemplate to find the failing branch.
- Consider letting ZodErrors surface their issues to the user so they can retry the prompt.
Example fix
// before: only the wrapped message reaches the caller
try {
sanitizeAndParseResumeJson(text);
} catch (e) {
console.log(e.message); // 'An unknown error occurred...'
}
// after: surface the original cause for debugging
throw new Error('An unknown error occurred while validating the merged resume data.', { cause: error }); Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate that the model output is parseable JSON before sending through sanitize.
function looksLikeCompleteJson(text: string): boolean {
const t = text.trim();
return t.startsWith('{') && t.endsWith('}') && JSON.parse(structuredClone(t).replace(/```json|```/g, ''));
} Try / catch
try {
const { data } = sanitizeAndParseResumeJson(text);
useResume(data);
} catch (err) {
if (err instanceof ZodError) showValidationIssues(err.issues);
else {
// The original cause was logged server-side; ask the user to retry.
retryPrompt('The model returned an unparseable resume. Please try again.');
}
} Prevention
- Increase model max_tokens to avoid truncated JSON.
- Trim the model output to the outermost JSON braces before sanitizing.
- Add the underlying cause via Error options for easier triage.
- Log the raw resultText alongside the error for post-mortem.
When it happens
Trigger: LLM returned text that jsonrepair cannot fix (e.g. truncated beyond repair); a custom coercer threw a non-Error value; structuredClone/merge failed on a cyclic object built from parsed JSON; an exception inside normalizeResumeDataForTemplate that isn't a Zod issue.
Common situations: Streaming truncation produced half a JSON object; the model emitted markdown fences or prose mixed with JSON that the boundary slicer couldn't clean; an upstream change to defaultResumeData introduced a non-serializable value.
Related errors
- BAD_REQUEST
- INTERNAL_SERVER_ERROR
- JSON.stringify(flattenError(error))
- Patch produced invalid resume data: ${error instanceof Error
- BAD_GATEWAY
AI-assisted analysis of amruthpillai/reactive-resume@3a5b12e2a4 (2026-08-12).
Data as JSON: /api/errors/9bee0d62a3119069.
Report an issue: GitHub.