{"record":{"id":"7f55df671e93062b","repo":"FlowiseAI/Flowise","slug":"invalid-condition-exception","errorCode":null,"errorMessage":"Invalid Condition: ${exception}","messagePattern":"Invalid Condition: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/sequentialagents/Condition/Condition.ts","lineNumber":326,"sourceCode":"                    }\n                } else if (item.variable.startsWith('$')) {\n                    const nodeId = item.variable.replace('$', '')\n\n                    const messageOutputs = ((state.messages as unknown as BaseMessage[]) ?? []).filter(\n                        (message) => message.additional_kwargs && message.additional_kwargs?.nodeId === nodeId\n                    )\n                    const messageOutput = messageOutputs[messageOutputs.length - 1]\n\n                    if (messageOutput) {\n                        if (checkCondition(messageOutput.content as string, item.operation, item.value)) {\n                            return item.output\n                        }\n                    }\n                }\n            }\n            return 'End'\n        } catch (exception) {\n            throw new Error('Invalid Condition: ' + exception)\n        }\n    }\n}\n\nmodule.exports = { nodeClass: Condition_SeqAgents }\n","sourceCodeStart":308,"sourceCodeEnd":332,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/sequentialagents/Condition/Condition.ts#L308-L332","documentation":"A catch-all wrapper around the `conditionUI` evaluation branch. Any exception thrown while parsing the conditionUI JSON, resolving `$flow`/`$vars` references via `customGet`, or indexing into `messageOutputs` is re-thrown with the `Invalid Condition:` prefix and the original exception appended.","triggerScenarios":"Malformed `conditionUI` JSON; a `$flow.x.y` path that does not exist (customGet returns undefined and downstream throws); accessing `messageOutputs[length-1]` when messages are not in the expected shape; an unsupported operation string.","commonSituations":"conditionUI was edited as raw JSON and broke syntax; the referenced `$flow.state.foo` path doesn't exist in the current graph; conversation history is empty so `messageOutputs` is empty; an `operation` was set that `checkCondition` does not handle.","solutions":["Validate `conditionUI` with `JSON.parse` before saving — fix any syntax errors.","Ensure every `$flow.*` and `$vars.*` path referenced in condition rows actually exists at runtime.","Use the UI grid editor rather than raw JSON so structure stays valid.","Inspect the appended exception text — it pinpoints the failing row or path."],"exampleFix":"// before\nconditionUI = '[{\"variable\":\"$flow.state.age\",\"operation\":\">\",\"value\":\"18\",\"output\":\"Approved\"},]' // trailing comma -> throws [294]\n\n// after\nconditionUI = '[{\"variable\":\"$flow.state.age\",\"operation\":\">\",\"value\":\"18\",\"output\":\"Approved\"}]'","handlingStrategy":"try-catch","validationCode":"function validateConditionUIStructure(raw) {\n  const items = typeof raw === 'string' ? JSON.parse(raw) : raw\n  if (!Array.isArray(items)) throw new Error('conditionUI must be a JSON array')\n  for (const item of items) {\n    if (!item.variable) throw new Error(`Row missing variable: ${JSON.stringify(item)}`)\n  }\n  return items\n}\n\nvalidateConditionUIStructure(nodeData.inputs.conditionUI)","typeGuard":"function resolvesFlowPath(flow, path): boolean {\n  const stripped = path.replace(/^\\$flow\\./, '')\n  return customGet(flow, stripped) !== undefined\n}","tryCatchPattern":"try {\n  const branch = await runCondition(nodeData, input, options, state)\n  return branch\n} catch (e) {\n  if (e?.message?.startsWith('Invalid Condition:')) {\n    // log the wrapped cause and fall back to the default branch\n    console.error('Condition eval failed, defaulting to End:', e.message)\n    return 'End'\n  }\n  throw e\n}","preventionTips":["Validate conditionUI JSON syntax before saving.","Confirm every `$flow.*` path exists in the running graph state.","Inspect the appended exception text to find the failing row or path."],"tags":["condition","runtime","error-wrapping","configuration"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}