fix(cli): fail when JSON input files cannot be parsed

This commit is contained in:
Kaoru0822
2026-10-06 03:02:22 -07:00
parent af48fe8791
commit 3201f0538d
4 changed files with 338 additions and 2 deletions
+9 -2
View File
@@ -60,14 +60,21 @@ export const analysisErrorProjectionSchema = z.discriminatedUnion("code", [
generic("execution_failure"),
]);
/** Legacy CLI envelope: a human label plus the canonical projected error fields. */
/** CLI label and input diagnostics surrounding the strict canonical error projection. */
export const analysisCliErrorEnvelopeSchema = z
.object({
error: z.string().min(1),
input_path: z.string().optional(),
input_reason: z.enum(["invalid-json", "read-failed"]).optional(),
})
.passthrough()
.superRefine((value, context) => {
const { error: _label, ...projection } = value;
const {
error: _label,
input_path: _inputPath,
input_reason: _inputReason,
...projection
} = value;
const parsed = analysisErrorProjectionSchema.safeParse(projection);
if (!parsed.success) {
context.addIssue({