fix: report malformed application evidence as input errors

This commit is contained in:
morluto
2026-10-10 03:52:35 +08:00
parent 55a46f7c71
commit 218c13160e
15 changed files with 613 additions and 165 deletions
+14 -1
View File
@@ -243,7 +243,20 @@ export const parseEvidenceBundle = (input: unknown): EvidenceBundle => {
throw new TypeError("Evidence bundle contains duplicate record IDs");
validateUnknownGraph(parsed.unknowns, parsed.records);
const canonical = createEvidenceBundle(
parsed.records.map(parseEvidence),
parsed.records.map((record, index) => {
try {
return parseEvidence(record);
} catch (cause: unknown) {
if (cause instanceof z.ZodError)
throw new z.ZodError(
cause.issues.map((issue) => ({
...issue,
path: ["records", index, ...issue.path],
})),
);
throw cause;
}
}),
parsed.unknowns,
);
if (JSON.stringify(parsed) !== JSON.stringify(canonical))