FlowiseAI/Flowise · error · Error
Invalid JSON in StructuredOutputParser: ${exception}
Error message
Invalid JSON in StructuredOutputParser: ${exception} What it means
StructuredOutputParser.init wraps its parser construction in try/catch and rethrows any failure as 'Invalid JSON in StructuredOutputParser'. The catch is broad — it captures failures from JSON.parse on the schema string, jsonrepair attempts, and defineProperty operations on the structured output parser instance.
Source
Thrown at packages/components/nodes/outputparsers/StructuredOutputParser/StructuredOutputParser.ts:95
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('Invalid JSON in StructuredOutputParser: ' + exception)
}
}
}
module.exports = { nodeClass: StructuredOutputParser }
View on GitHub (pinned to abe4a8601a)
Solutions
- Validate the schema JSON with a JSON linter before pasting.
- Inspect `exception.message` for the parse offset and fix the cited location.
- If jsonrepair is failing, simplify the schema to find the unparseable fragment.
- Ensure the schema string is a plain JSON object, not a JS object literal.
Example fix
// before
} catch (exception) {
throw new Error('Invalid JSON in StructuredOutputParser: ' + exception)
}
// after
} catch (exception) {
const msg = exception instanceof Error ? exception.message : String(exception)
throw new Error(`Invalid JSON in StructuredOutputParser: ${msg}. Input was: ${jsonString?.slice(0, 200)}`)
} Defensive patterns
Strategy: validation
Validate before calling
function safeParseSchema(s: string): unknown {
try { return JSON.parse(s) }
catch {
try { return JSON.parse(jsonrepair(s)) }
catch (e) { throw new Error(`Schema JSON unparseable: ${(e as Error).message}`) }
}
} Type guard
const isJsonString = (s: string): boolean => { try { JSON.parse(s); return true } catch { return false } } Try / catch
try { /* build parser */ }
catch (e) { throw new Error(`StructuredOutputParser failed: ${(e as Error).message}. Input: ${jsonString.slice(0,200)}`) } Prevention
- Lint schema JSON externally before pasting.
- Avoid JS object literals and comments.
- Inspect parse error offsets to locate the bad fragment.
When it happens
Trigger: The schema JSON input is malformed (unbalanced braces, single quotes, trailing commas); the jsonrepair library cannot recover the string; defineProperty fails on a frozen/sealed parser instance.
Common situations: Hand-editing the JSON schema field; passing a schema string that includes comments or JS object syntax; version mismatch where the structured output parser shape changed.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Error parsing Zod Schema: ${exception}
- Invalid JSON in the Chat NVIDIA NIM's baseOptions: ${excepti
- Invalid JSON in the ChatOpenAI's BaseOptions: ${exception}
- Invalid JSON in the ChatOpenAI's BaseOptions: ${exception}
- Invalid JSON in the ChatOpenRouter's BaseOptions: ${exceptio
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/962bc15aa876e9ff.
Report an issue: GitHub.