FlowiseAI/Flowise · error · Error

Invalid JSON in the Custom Function Input Variables: ${excep

Error message

Invalid JSON in the Custom Function Input Variables: ${exception}

What it means

The Custom Function's 'Input Variables' field is parsed at runtime (inside executeFunc) with JSON.parse when it is a string. If the string is not valid JSON, the SyntaxError is caught and re-thrown with this prefix. This is a runtime error, not an init error — it surfaces only when the node actually executes.

Source

Thrown at packages/components/nodes/sequentialagents/CustomFunction/CustomFunction.ts:119

        if (!sequentialNodes || !sequentialNodes.length) throw new Error('Custom function must have a predecessor!')

        const executeFunc = async (state: ISeqAgentsState) => {
            const variables = await getVars(appDataSource, databaseEntities, nodeData, options)
            const flow = {
                chatflowId: options.chatflowid,
                sessionId: options.sessionId,
                chatId: options.chatId,
                input,
                state
            }

            let inputVars: ICommonObject = {}
            if (functionInputVariablesRaw) {
                try {
                    inputVars =
                        typeof functionInputVariablesRaw === 'object' ? functionInputVariablesRaw : JSON.parse(functionInputVariablesRaw)
                } catch (exception) {
                    throw new Error('Invalid JSON in the Custom Function Input Variables: ' + exception)
                }
            }

            // Some values might be a stringified JSON, parse it
            for (const key in inputVars) {
                let value = inputVars[key]
                if (typeof value === 'string') {
                    value = handleEscapeCharacters(value, true)
                    if (value.startsWith('{') && value.endsWith('}')) {
                        try {
                            value = JSON.parse(value)
                            const nodeId = value.id || ''
                            if (nodeId) {
                                const messages = state.messages as unknown as BaseMessage[]
                                const content = messages.find((msg) => msg.additional_kwargs?.nodeId === nodeId)?.content
                                if (content) {
                                    value = content
                                }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Paste the current Input Variables value into a JSON linter (e.g. jsonlint.com) and fix the reported syntax error.
  2. Prefer the structured Input Variables editor over raw JSON so the field is always a valid object.
  3. For a single variable, use the minimal shape {"name":"value"}.

Example fix

// before (throws)
{"theme": "sales", "limit": 5,}

// after
{"theme": "sales", "limit": 5}
Defensive patterns

Strategy: validation

Validate before calling

function parseInputVars(raw: unknown): Record<string, unknown> {
  if (!raw) return {}
  const obj = typeof raw === 'string' ? JSON.parse(raw) : raw
  if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) throw new Error('Input Variables must be a JSON object')
  return obj as Record<string, unknown>
}

Type guard

const isInputVarsObject = (x: any): x is Record<string, unknown> =>
  typeof x === 'object' && x !== null && !Array.isArray(x)

Try / catch

try { JSON.parse(functionInputVariablesRaw) } catch (e) { throw new Error('Input Variables JSON invalid: ' + e.message) }

Prevention

When it happens

Trigger: functionInputVariablesRaw is a non-empty string containing a trailing comma, unquoted key, smart/curly quotes, a truncated value, or single quotes instead of double quotes; the field was hand-typed instead of using the structured editor.

Common situations: Pasting JSON from documentation that introduced smart quotes; partial edit left mid-typing before a test run; exporting then re-importing a flow with mangled escaping.

Understand the failure class

Related errors


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