{"record":{"id":"5828e0b29369bd03","repo":"FlowiseAI/Flowise","slug":"error-parsing-zod-schema-exception","errorCode":null,"errorMessage":"Error parsing Zod Schema: ${exception}","messagePattern":"Error parsing Zod Schema: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/outputparsers/StructuredOutputParserAdvanced/StructuredOutputParserAdvanced.ts","lineNumber":81,"sourceCode":"\n            const baseParse = structuredOutputParser.parse\n\n            // Fix broken JSON from LLM\n            structuredOutputParser.parse = (text) => {\n                const jsonString = text.includes('```') ? text.trim().split(/```(?:json)?/)[1] : text.trim()\n                return baseParse.call(structuredOutputParser, jsonrepair(jsonString))\n            }\n\n            // NOTE: When we change Flowise to return a json response, the following has to be changed to: JsonStructuredOutputParser\n            Object.defineProperty(structuredOutputParser, 'autoFix', {\n                enumerable: true,\n                configurable: true,\n                writable: true,\n                value: autoFix\n            })\n            return structuredOutputParser\n        } catch (exception) {\n            throw new Error('Error parsing Zod Schema: ' + exception)\n        }\n    }\n}\n\nmodule.exports = { nodeClass: AdvancedStructuredOutputParser }\n","sourceCodeStart":63,"sourceCodeEnd":87,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/outputparsers/StructuredOutputParserAdvanced/StructuredOutputParserAdvanced.ts#L63-L87","documentation":"StructuredOutputParserAdvanced.init catches any failure during parser construction and rethrows as 'Error parsing Zod Schema'. The advanced variant builds a Zod schema from user input and uses jsonrepair + autoFix; the catch covers Zod schema build errors, JSON parse errors, and defineProperty failures.","triggerScenarios":"Zod schema definition string is invalid Zod syntax; JSON describing fields is malformed; a field type is unsupported by the Zod builder; jsonrepair cannot reconstruct the JSON.","commonSituations":"Authoring a complex nested schema with an unsupported Zod type; pasting a JSON field spec with type errors; version drift where Zod changed an API.","solutions":["Run the Zod schema through `z.object(...).safeParse` in isolation to isolate the build error.","Inspect `exception.message` — Zod errors are usually specific about which field failed.","Reduce the schema to the minimal failing field and fix incrementally.","Ensure field types match Zod's supported set (string, number, boolean, array, object, enum)."],"exampleFix":"// before\n} catch (exception) {\n  throw new Error('Error parsing Zod Schema: ' + exception)\n}\n// after\n} catch (exception) {\n  const msg = exception instanceof Error ? exception.message : String(exception)\n  throw new Error(`Error parsing Zod Schema: ${msg}. Schema input: ${jsonString?.slice(0, 200)}`)\n}","handlingStrategy":"validation","validationCode":"import { z } from 'zod'\nfunction validateZodBuild(spec: unknown) {\n  try { z.object(spec as any) }\n  catch (e) { throw new Error(`Zod schema invalid: ${(e as Error).message}`) }\n}","typeGuard":null,"tryCatchPattern":"try { /* build zod parser */ }\ncatch (e) { throw new Error(`Zod schema build failed: ${(e as Error).message}. Spec: ${jsonString.slice(0,200)}`) }","preventionTips":["Test Zod schemas in isolation before embedding them.","Stick to supported field types.","Watch for Zod major-version API changes."],"tags":["zod","json","output-parser","schema","validation"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}