{"record":{"id":"f9b63055625a7c9f","repo":"FlowiseAI/Flowise","slug":"e-f9b630","errorCode":null,"errorMessage":"${e}","messagePattern":"\\$\\{e\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/utilities/IfElseFunction/IfElseFunction.ts","lineNumber":143,"sourceCode":"        if (Object.keys(inputVars).length) {\n            for (const item in inputVars) {\n                additionalSandbox[`$${item}`] = inputVars[item]\n            }\n        }\n\n        const sandbox = createCodeExecutionSandbox(input, variables, flow, additionalSandbox)\n\n        try {\n            const responseTrue = await executeJavaScriptCode(ifFunction, sandbox)\n\n            if (responseTrue)\n                return { output: typeof responseTrue === 'string' ? handleEscapeCharacters(responseTrue, false) : responseTrue, type: true }\n\n            const responseFalse = await executeJavaScriptCode(elseFunction, sandbox)\n\n            return { output: typeof responseFalse === 'string' ? handleEscapeCharacters(responseFalse, false) : responseFalse, type: false }\n        } catch (e) {\n            throw new Error(e)\n        }\n    }\n}\n\nmodule.exports = { nodeClass: IfElseFunction_Utilities }\n","sourceCodeStart":125,"sourceCodeEnd":149,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/utilities/IfElseFunction/IfElseFunction.ts#L125-L149","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Test each branch function standalone with representative inputs.","Determine which branch failed by checking which condition would have evaluated; the tool tries ifFunction first.","Add input guards inside the user functions and throw descriptive errors.","Confirm sandbox variables (input, variables, flow, additionalSandbox) are populated as expected."],"exampleFix":"// before (branch throws, library re-wraps)\n// ifFunction\nfunction run(input) { return JSON.parse(input.missingField) }\n\n// after\nfunction run(input) {\n  if (!input || typeof input.missingField !== 'string') throw new Error('expected string input.missingField')\n  return JSON.parse(input.missingField)\n}","handlingStrategy":"try-catch","validationCode":"async function dryRunBranch(fnSource: string, sandbox: Record<string, unknown>) {\n  try {\n    const fn = new Function(...Object.keys(sandbox), fnSource)\n    return await fn(...Object.values(sandbox))\n  } catch (e) {\n    throw new Error(`Branch function validation failed: ${(e as Error).message}`)\n  }\n}\n// validate both branches before the node runs\nawait dryRunBranch(ifFunction, sandbox)\nawait dryRunBranch(elseFunction, sandbox)","typeGuard":"const isBranchSyntaxError = (e: unknown): boolean =>\n  /unexpected token|unexpected end|syntaxerror/i.test(e instanceof Error ? e.message : String(e))","tryCatchPattern":"try {\n  return await ifElseNode.init(nodeData, input, options)\n} catch (e) {\n  const msg = (e as Error).message\n  if (/is not defined|unexpected token|is not a function|cannot read prop/i.test(msg)) {\n    throw new Error(`Bug in if/else branch function: ${msg}`)\n  }\n  throw e\n}","preventionTips":["Test each branch standalone with realistic inputs.","Assert all sandbox variables the branches reference are populated.","Add input-shape guards inside the user functions.","Keep branch functions small and pure."],"tags":["javascript","sandbox","user-code","if-else","error-wrapping"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}