FlowiseAI/Flowise · error · Error
Invalid object syntax
Error message
Invalid object syntax
What it means
When a property value is a nested z.object(...) followed by modifiers (e.g. '.optional()'), extractObjectWithModifiers splits off the object part; if that object part still does not match /z\.object\(\s*\{([\s\S]*)\}\s*\)/, this throws. It indicates a nested object that has modifiers AND a malformed/missing brace body.
Source
Thrown at packages/components/src/secureZodParser.ts:146
private static parseProperty(prop: string): [string | null, any] {
const colonIndex = prop.indexOf(':')
if (colonIndex === -1) return [null, null]
const key = prop.substring(0, colonIndex).trim().replace(/['"]/g, '')
const value = prop.substring(colonIndex + 1).trim()
return [key, this.parseZodType(value)]
}
private static parseZodType(typeStr: string): any {
// Check if this is a nested object (not in an array)
if (typeStr.startsWith('z.object(') && !typeStr.startsWith('z.array(')) {
// Check if there are modifiers after the object
const objectWithModifiers = this.extractObjectWithModifiers(typeStr)
if (objectWithModifiers.hasModifiers) {
const objectMatch = objectWithModifiers.objectPart.match(/z\.object\(\s*\{([\s\S]*)\}\s*\)/)
if (!objectMatch) {
throw new Error('Invalid object syntax')
}
const objectContent = objectMatch[1]
const objectProperties = this.parseObjectProperties(objectContent)
return {
isNestedObject: true,
objectSchema: objectProperties,
modifiers: objectWithModifiers.modifiers
}
}
// Original code for objects without modifiers
const objectMatch = typeStr.match(/z\.object\(\s*\{([\s\S]*)\}\s*\)/)
if (!objectMatch) {
throw new Error('Invalid object syntax')
}
View on GitHub (pinned to abe4a8601a)
Solutions
- Give the nested object a complete brace body: 'addr: z.object({ city: z.string() }).optional()'.
- Ensure braces are balanced before any trailing modifier.
Example fix
// before
'z.object({ addr: z.object().optional() })'
// after
'z.object({ addr: z.object({ city: z.string() }).optional() })' Defensive patterns
Strategy: validation
Validate before calling
// For nested-object-with-modifier values, ensure the object part has a brace body.
const validNestedObjWithMod = (v: string): boolean => {
const m = v.match(/^(z\.object\(\s*\{[\s\S]*?\}\s*\))\..+$/)
return !!m
} Prevention
- Give nested objects a complete brace body before any modifier.
- Use 'prop: z.object({...}).optional()' rather than 'z.object().optional()'.
When it happens
Trigger: 'addr: z.object().optional()' (nested object with no body + modifier), or a nested object with unbalanced braces followed by '.optional()' / '.default(...)'.
Common situations: Marking an optional nested object but forgetting its body; copy-paste that drops the inner '{}'.
Related errors
- Invalid object syntax inside array
- Failed to parse Zod schema: ${error.message}
- Schema must start with z.object()
- Invalid z.object() syntax
- Expected 'z' but got '${part}'
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/379ddde5a4e33041.
Report an issue: GitHub.