FlowiseAI/Flowise · error · Error
Invalid Condition: ${exception}
Error message
Invalid Condition: ${exception} What it means
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.
Source
Thrown at packages/components/nodes/sequentialagents/Condition/Condition.ts:326
}
} else if (item.variable.startsWith('$')) {
const nodeId = item.variable.replace('$', '')
const messageOutputs = ((state.messages as unknown as BaseMessage[]) ?? []).filter(
(message) => message.additional_kwargs && message.additional_kwargs?.nodeId === nodeId
)
const messageOutput = messageOutputs[messageOutputs.length - 1]
if (messageOutput) {
if (checkCondition(messageOutput.content as string, item.operation, item.value)) {
return item.output
}
}
}
}
return 'End'
} catch (exception) {
throw new Error('Invalid Condition: ' + exception)
}
}
}
module.exports = { nodeClass: Condition_SeqAgents }
View on GitHub (pinned to abe4a8601a)
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.
Example fix
// before
conditionUI = '[{"variable":"$flow.state.age","operation":">","value":"18","output":"Approved"},]' // trailing comma -> throws [294]
// after
conditionUI = '[{"variable":"$flow.state.age","operation":">","value":"18","output":"Approved"}]' Defensive patterns
Strategy: try-catch
Validate before calling
function validateConditionUIStructure(raw) {
const items = typeof raw === 'string' ? JSON.parse(raw) : raw
if (!Array.isArray(items)) throw new Error('conditionUI must be a JSON array')
for (const item of items) {
if (!item.variable) throw new Error(`Row missing variable: ${JSON.stringify(item)}`)
}
return items
}
validateConditionUIStructure(nodeData.inputs.conditionUI) Type guard
function resolvesFlowPath(flow, path): boolean {
const stripped = path.replace(/^\$flow\./, '')
return customGet(flow, stripped) !== undefined
} Try / catch
try {
const branch = await runCondition(nodeData, input, options, state)
return branch
} catch (e) {
if (e?.message?.startsWith('Invalid Condition:')) {
// log the wrapped cause and fall back to the default branch
console.error('Condition eval failed, defaulting to End:', e.message)
return 'End'
}
throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Condition function must return a string
- Condition variable is required!
- Condition function must return a string
- Condition variable is required!
- Invalid Condition: ${exception}
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/7f55df671e93062b.
Report an issue: GitHub.