FlowiseAI/Flowise · error · Error

Error parsing Zod Schema: ${exception}

Error message

Error parsing Zod Schema: ${exception}

What it means

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.

Source

Thrown at packages/components/nodes/outputparsers/StructuredOutputParserAdvanced/StructuredOutputParserAdvanced.ts:81

            const baseParse = structuredOutputParser.parse

            // Fix broken JSON from LLM
            structuredOutputParser.parse = (text) => {
                const jsonString = text.includes('```') ? text.trim().split(/```(?:json)?/)[1] : text.trim()
                return baseParse.call(structuredOutputParser, jsonrepair(jsonString))
            }

            // NOTE: When we change Flowise to return a json response, the following has to be changed to: JsonStructuredOutputParser
            Object.defineProperty(structuredOutputParser, 'autoFix', {
                enumerable: true,
                configurable: true,
                writable: true,
                value: autoFix
            })
            return structuredOutputParser
        } catch (exception) {
            throw new Error('Error parsing Zod Schema: ' + exception)
        }
    }
}

module.exports = { nodeClass: AdvancedStructuredOutputParser }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Run the Zod schema through `z.object(...).safeParse` in isolation to isolate the build error.
  2. Inspect `exception.message` — Zod errors are usually specific about which field failed.
  3. Reduce the schema to the minimal failing field and fix incrementally.
  4. Ensure field types match Zod's supported set (string, number, boolean, array, object, enum).

Example fix

// before
} catch (exception) {
  throw new Error('Error parsing Zod Schema: ' + exception)
}
// after
} catch (exception) {
  const msg = exception instanceof Error ? exception.message : String(exception)
  throw new Error(`Error parsing Zod Schema: ${msg}. Schema input: ${jsonString?.slice(0, 200)}`)
}
Defensive patterns

Strategy: validation

Validate before calling

import { z } from 'zod'
function validateZodBuild(spec: unknown) {
  try { z.object(spec as any) }
  catch (e) { throw new Error(`Zod schema invalid: ${(e as Error).message}`) }
}

Try / catch

try { /* build zod parser */ }
catch (e) { throw new Error(`Zod schema build failed: ${(e as Error).message}. Spec: ${jsonString.slice(0,200)}`) }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/5828e0b29369bd03. Report an issue: GitHub.