{"record":{"id":"1d0eefb85ae54159","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-ifelse-s-input-variables-ex","errorCode":null,"errorMessage":"Invalid JSON in the IfElse's Input Variables: ${exception}","messagePattern":"Invalid JSON in the IfElse's Input Variables: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/utilities/IfElseFunction/IfElseFunction.ts","lineNumber":101,"sourceCode":"        const functionInputVariablesRaw = nodeData.inputs?.functionInputVariables\n        const appDataSource = options.appDataSource as DataSource\n        const databaseEntities = options.databaseEntities as IDatabaseEntity\n\n        const variables = await getVars(appDataSource, databaseEntities, nodeData, options)\n        const flow = {\n            chatflowId: options.chatflowid,\n            sessionId: options.sessionId,\n            chatId: options.chatId,\n            input\n        }\n\n        let inputVars: ICommonObject = {}\n        if (functionInputVariablesRaw) {\n            try {\n                inputVars =\n                    typeof functionInputVariablesRaw === 'object' ? functionInputVariablesRaw : JSON.parse(functionInputVariablesRaw)\n            } catch (exception) {\n                throw new Error(\"Invalid JSON in the IfElse's Input Variables: \" + exception)\n            }\n        }\n\n        // Some values might be a stringified JSON, parse it\n        for (const key in inputVars) {\n            let value = inputVars[key]\n            if (typeof value === 'string') {\n                value = handleEscapeCharacters(value, true)\n                if (value.startsWith('{') && value.endsWith('}')) {\n                    try {\n                        value = JSON.parse(value)\n                    } catch (e) {\n                        // ignore\n                    }\n                }\n                inputVars[key] = value\n            }\n        }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/utilities/IfElseFunction/IfElseFunction.ts#L83-L119","documentation":"Thrown by IfElseFunction_Utilities.init when JSON.parse fails on `functionInputVariablesRaw`. Structurally identical to error 492 in CustomFunction: a non-object value is treated as a JSON string and parsed; failure aborts before the if/else sandbox runs.","triggerScenarios":"Malformed JSON in the IfElse node's Input Variables field; a flow variable returns a non-JSON string; trailing comma, unquoted keys, smart quotes, truncation.","commonSituations":"Hand-typed JSON with a syntax error; copy-paste from a rich-text editor; variable resolved to a partial string; mixed quote styles.","solutions":["Validate the JSON in an external linter before saving the node.","If the value is an object at runtime, pass it as an object to skip parsing.","Trim whitespace/escape characters and retry.","Use a JSON editor with syntax checking."],"exampleFix":"// before (malformed)\nfunctionInputVariablesRaw = \"{ a: 1, }\" // throws: Invalid JSON in the IfElse's Input Variables\n\n// after (valid)\nfunctionInputVariablesRaw = '{\"a\":1}'","handlingStrategy":"validation","validationCode":"function parseIfElseInputVars(raw: unknown): Record<string, unknown> {\n  if (raw == null) return {}\n  if (typeof raw === 'object') return raw as Record<string, unknown>\n  try { return JSON.parse(raw as string) }\n  catch (e) { throw new Error(`IfElse Input Variables is not valid JSON: ${(e as Error).message}`) }\n}","typeGuard":"const isParsableJson = (v: unknown): boolean => {\n  if (typeof v === 'object' && v !== null) return true\n  if (typeof v !== 'string') return false\n  try { JSON.parse(v); return true } catch { return false }\n}","tryCatchPattern":"try { JSON.parse(functionInputVariablesRaw as string) }\ncatch (e) { throw new Error(`Fix the IfElse Input Variables JSON: ${(e as Error).message}`) }","preventionTips":["Use a JSON-aware editor for node config.","Pass objects directly when possible to skip parsing.","Lint flow definitions in CI.","Avoid rich-text copy-paste of JSON."],"tags":["json","parsing","configuration","if-else"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}