FlowiseAI/Flowise · error · Error

Failed to parse Supabase filter: ${error.message}

Error message

Failed to parse Supabase filter: ${error.message}

What it means

`FilterParser.parseFilterString` is the top-level entry that cleans the filter string, parses the method chain, and builds a safe function. Any error thrown by those inner steps is caught here and re-thrown prefixed with 'Failed to parse Supabase filter:'. It is an umbrella message — the real reason (disallowed method/operator, dangerous argument, empty chain) is in `error.message` appended to the prefix.

Source

Thrown at packages/components/nodes/vectorstores/Supabase/filterParser.ts:48

    /**
     * Safely parse a Supabase RPC filter string into a function
     * @param filterString The filter string (e.g., 'filter("metadata->a::int", "gt", 5).filter("metadata->c::int", "gt", 7)')
     * @returns A function that can be applied to an RPC object
     * @throws Error if the filter string contains unsafe patterns
     */
    static parseFilterString(filterString: string): (rpc: any) => any {
        try {
            // Clean and validate the filter string
            const cleanedFilter = this.cleanFilterString(filterString)

            // Parse the filter chain
            const filterChain = this.parseFilterChain(cleanedFilter)

            // Build the safe filter function
            return this.buildFilterFunction(filterChain)
        } catch (error) {
            throw new Error(`Failed to parse Supabase filter: ${error.message}`)
        }
    }

    private static cleanFilterString(filter: string): string {
        // Remove comments and normalize whitespace
        filter = filter.replace(/\/\/.*$/gm, '').replace(/\/\*[\s\S]*?\*\//g, '')
        filter = filter.replace(/\s+/g, ' ').trim()

        // Remove trailing semicolon if present
        if (filter.endsWith(';')) {
            filter = filter.slice(0, -1).trim()
        }

        return filter
    }

    private static parseFilterChain(filter: string): Array<{ method: string; args: any[] }> {
        const chain: Array<{ method: string; args: any[] }> = []

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Read the appended inner message to find the specific sub-error (method/operator/argument).
  2. Restrict the filter string to the documented DSL: only `filter|order|limit|range|single|maybeSingle` with allowed operators.
  3. Validate the filter string client-side before sending it to parseFilterString.
  4. Strip comments and trailing semicolons (the parser does this, but avoid relying on it).

Example fix

// before
FilterParser.parseFilterString(userInput)  // throws generic 'Failed to parse Supabase filter: ...'

// after (surface inner cause)
try { FilterParser.parseFilterString(userInput) }
catch (e) { throw new Error(`Filter '${userInput}' rejected: ${e.message}`) }
Defensive patterns

Strategy: validation

Validate before calling

function tryParseFilter(s: string) {
  try { return FilterParser.parseFilterString(s) }
  catch (e) { throw new Error(`Filter rejected ('${s}'): ${(e as Error).message}`) }
}

Type guard

function isFilterString(v: unknown): v is string { return typeof v === 'string' && v.trim().length > 0 }

Try / catch

try { fn = FilterParser.parseFilterString(raw) } catch (e) { /* read appended inner cause */ throw new Error(`Bad filter: ${(e as Error).message}`) }

Prevention

When it happens

Trigger: Passing any malformed or unsupported filter string: unknown method, unknown operator, empty string, dangerous token (require/process/eval/Function), unparseable arguments, or a method not callable on the RPC at build time.

Common situations: User-authored filter from a chatflow textarea with a typo; filter built for a different Supabase version; copy-paste of raw PostgREST syntax the mini-DSL does not support.

Understand the failure class

Related errors


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