amruthpillai/reactive-resume · warning · Error
JSON.stringify(flattenError(error))
Error message
JSON.stringify(flattenError(error))
What it means
rethrowAsImportError converts a ZodError from resume parsing into a generic Error whose message is the JSON-serialized flattened error (issue + form errors). It is thrown during resume import when the imported payload, after transformation, fails the resume Zod schema. The message string is intentionally machine-readable JSON, not prose.
Source
Thrown at packages/import/src/error.ts:6
import { flattenError, ZodError } from "zod";
/** Rethrows a ZodError as a serialized string error; re-throws other errors as-is. */
export function rethrowAsImportError(error: unknown): never {
if (error instanceof ZodError) {
throw new Error(JSON.stringify(flattenError(error)));
}
throw error;
}
View on GitHub (pinned to 3a5b12e2a4)
Solutions
- Catch the error and JSON.parse(err.message) to display the flattened field errors to the user.
- Pre-validate the imported object against the public resume schema before calling the import pipeline.
- Update the export source to include all required resume fields for the current schema version.
- If migrating an old export, run it through the schema migration/upgrade step before import.
Example fix
// before: surfacing raw JSON message
try { await importResume(file); }
catch (e) { toast.error(String(e.message)); }
// after: parse and display flattened errors
try { await importResume(file); }
catch (e) {
const flat = safeJsonParse(e.message);
toast.error(flat ? formatFlattened(flat) : 'Import failed');
} Defensive patterns
Strategy: try-catch
Validate before calling
import { parseResumeData } from '@reactive-resume/schema';
const parsed = parseResumeData(raw); // throws ZodError before the import pipeline does Type guard
function isSerializedZod(e: unknown): boolean {
if (!(e instanceof Error)) return false;
try { JSON.parse(e.message); return true; } catch { return false; }
} Try / catch
try { await importResume(file); }
catch (e) {
const flat = isSerializedZod(e) ? JSON.parse((e as Error).message) : null;
ui.error(flat ? formatFlattened(flat) : 'Import failed');
} Prevention
- Pre-validate imports against the public resume schema.
- Migrate old exports to the current schema before import.
- Display flattened field errors to the user.
When it happens
Trigger: Importing a JSON/ZIP/LinkedIn/Reactive-Resume export whose structure does not match the current resume schema; a version skew between the export producer and the running schema; a partially-corrupt export.
Common situations: User uploads an export from an older/newer Reactive Resume version; a third-party 'resume.json' missing required fields; an import adapter that didn't fill required defaults.
Related errors
- BAD_REQUEST
- Patch produced invalid resume data: ${error instanceof Error
- An unknown error occurred while validating the merged resume
- BAD_REQUEST
- INTERNAL_SERVER_ERROR
AI-assisted analysis of amruthpillai/reactive-resume@3a5b12e2a4 (2026-08-12).
Data as JSON: /api/errors/cf05a5a0765d65de.
Report an issue: GitHub.