FlowiseAI/Flowise · error · Error

${e}

Error message

${e}

What it means

Thrown by IfElseFunction_Utilities.init as the catch-all around executeJavaScriptCode for both the `ifFunction` and `elseFunction` user code. One of the two branches threw (syntax/runtime error). Same `throw new Error(e)` pattern as 493 loses the original stack and error type.

Source

Thrown at packages/components/nodes/utilities/IfElseFunction/IfElseFunction.ts:143

        if (Object.keys(inputVars).length) {
            for (const item in inputVars) {
                additionalSandbox[`$${item}`] = inputVars[item]
            }
        }

        const sandbox = createCodeExecutionSandbox(input, variables, flow, additionalSandbox)

        try {
            const responseTrue = await executeJavaScriptCode(ifFunction, sandbox)

            if (responseTrue)
                return { output: typeof responseTrue === 'string' ? handleEscapeCharacters(responseTrue, false) : responseTrue, type: true }

            const responseFalse = await executeJavaScriptCode(elseFunction, sandbox)

            return { output: typeof responseFalse === 'string' ? handleEscapeCharacters(responseFalse, false) : responseFalse, type: false }
        } catch (e) {
            throw new Error(e)
        }
    }
}

module.exports = { nodeClass: IfElseFunction_Utilities }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Test each branch function standalone with representative inputs.
  2. Determine which branch failed by checking which condition would have evaluated; the tool tries ifFunction first.
  3. Add input guards inside the user functions and throw descriptive errors.
  4. Confirm sandbox variables (input, variables, flow, additionalSandbox) are populated as expected.

Example fix

// before (branch throws, library re-wraps)
// ifFunction
function run(input) { return JSON.parse(input.missingField) }

// after
function run(input) {
  if (!input || typeof input.missingField !== 'string') throw new Error('expected string input.missingField')
  return JSON.parse(input.missingField)
}
Defensive patterns

Strategy: try-catch

Validate before calling

async function dryRunBranch(fnSource: string, sandbox: Record<string, unknown>) {
  try {
    const fn = new Function(...Object.keys(sandbox), fnSource)
    return await fn(...Object.values(sandbox))
  } catch (e) {
    throw new Error(`Branch function validation failed: ${(e as Error).message}`)
  }
}
// validate both branches before the node runs
await dryRunBranch(ifFunction, sandbox)
await dryRunBranch(elseFunction, sandbox)

Type guard

const isBranchSyntaxError = (e: unknown): boolean =>
  /unexpected token|unexpected end|syntaxerror/i.test(e instanceof Error ? e.message : String(e))

Try / catch

try {
  return await ifElseNode.init(nodeData, input, options)
} catch (e) {
  const msg = (e as Error).message
  if (/is not defined|unexpected token|is not a function|cannot read prop/i.test(msg)) {
    throw new Error(`Bug in if/else branch function: ${msg}`)
  }
  throw e
}

Prevention

When it happens

Trigger: The if-function or else-function references an undefined sandbox variable, has a syntax error, throws explicitly, or fails an operation (e.g. calling a method on undefined).

Common situations: Typo in branch function; branch assumes a variable not provided in the sandbox; logic bug; copy-paste syntax error; the branch condition type does not match what the code expects.

Related errors


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