FlowiseAI/Flowise · error · Error

Invalid z.object() syntax

Error message

Invalid z.object() syntax

What it means

The cleaned schema starts with 'z.object(' but the regex /z\.object\(\s*\{([\s\S]*)\}\s*\)/ fails to match — i.e. there is no '{ ... }' body. This fires for z.object() with no braces, z.object(null), z.object(123), or any z.object whose argument is not a brace-wrapped object literal.

Source

Thrown at packages/components/src/secureZodParser.ts:68

        // Normalize whitespace
        schema = schema.replace(/\s+/g, ' ').trim()

        return schema
    }

    private static parseSchemaStructure(schema: string): any {
        // This is a simplified parser that handles common Zod patterns safely
        // It does NOT use eval/Function and only handles predefined safe patterns

        if (!schema.startsWith('z.object(')) {
            throw new Error('Schema must start with z.object()')
        }

        // Extract the object content
        const objectMatch = schema.match(/z\.object\(\s*\{([\s\S]*)\}\s*\)/)
        if (!objectMatch) {
            throw new Error('Invalid z.object() syntax')
        }

        const objectContent = objectMatch[1]
        return this.parseObjectProperties(objectContent)
    }

    private static parseObjectProperties(content: string): Record<string, any> {
        const properties: Record<string, any> = {}

        // Split by comma, but handle nested structures
        const props = this.splitProperties(content)

        for (const prop of props) {
            const [key, value] = this.parseProperty(prop)
            if (key && value) {
                properties[key] = value
            }
        }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Always provide a brace-wrapped body, even when empty: 'z.object({})'.
  2. Ensure the closing '})' is present.

Example fix

// before
'z.object()'

// after
'z.object({})'
Defensive patterns

Strategy: validation

Validate before calling

const hasObjectBody = (s: string): boolean => /z\.object\(\s*\{[\s\S]*\}\s*\)/.test(s)

Prevention

When it happens

Trigger: 'z.object()', 'z.object(null)', 'z.object(123)', or a body where the opening '{' or closing '}' is missing.

Common situations: Trying to define an empty object schema without braces; passing a variable reference as the object argument.

Related errors


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