FlowiseAI/Flowise · error · Error
Invalid Condition: ${exception}
Error message
Invalid Condition: ${exception} What it means
Catch-all thrown by the Condition node's UI-grid evaluator (conditionUI branch). Any inner failure during condition evaluation — JSON.parse of the grid, customGet on a $flow/$vars path, checkCondition's type coercion, or casting messageOutput.content to string — is caught and re-thrown with the prefix 'Invalid Condition: ' plus the original exception. The wrapper preserves the root cause in its suffix, so read the appended text to find the real failure.
Source
Thrown at packages/components/nodes/sequentialagents/ConditionAgent/ConditionAgent.ts:595
}
} 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: ConditionAgent_SeqAgents }
View on GitHub (pinned to abe4a8601a)
Solutions
- Read the text appended after 'Invalid Condition: ' — it names the real error (SyntaxError for JSON, TypeError for a bad cast, etc.).
- Validate the conditionUI JSON in a linter; confirm it is an array of {variable, operation, value, output} items.
- For every item.variable starting with '$', confirm the referenced nodeId still exists and produced a message in state.messages.
- If the upstream node emits array/object content, flatten it to a string before it reaches the comparison, or reference a $flow./$vars. scalar instead.
Example fix
// before: casts multi-part content to string, throws on .content being an array
if (checkCondition(messageOutput.content as string, item.operation, item.value)) { return item.output }
// after: normalize content to a string first
const raw = messageOutput.content
const text = typeof raw === 'string' ? raw : Array.isArray(raw) ? raw.map(p => typeof p === 'string' ? p : p?.text ?? '').join('') : String(raw ?? '')
if (checkCondition(text, item.operation, item.value)) { return item.output } Defensive patterns
Strategy: try-catch
Validate before calling
function validateConditionGrid(conditionUI: unknown): {variable:string;operation:string;value:any;output:string}[] {
const items = typeof conditionUI === 'string' ? JSON.parse(conditionUI) : conditionUI
if (!Array.isArray(items)) throw new Error('conditionUI must be an array')
return items.map((it, i) => {
if (!it || !it.variable) throw new Error(`Row ${i}: variable is required`)
return it
})
} Type guard
const isConditionItem = (x: any): x is {variable:string;operation:string;value:any;output:string} =>
!!x && typeof x === 'object' && typeof x.variable === 'string' && typeof x.operation === 'string' Try / catch
try {
// evaluate condition grid
} catch (e) {
// unwrap the 'Invalid Condition: <inner>' prefix to inspect the real cause
const inner = String(e?.message ?? e).replace(/^Invalid Condition:\s*/, '')
logger.error({ inner }, 'condition evaluation failed')
throw e
} Prevention
- Always validate the conditionUI JSON and each item's variable field before deploying.
- Keep upstream node ids stable — never rename/delete a node that a $-reference points at without updating the grid.
- Treat multi-part LLM content as potentially non-string and normalize before comparison.
When it happens
Trigger: The conditionUI value is a non-empty string that fails JSON.parse; a grid item.variable is undefined (caught by the explicit 'Condition variable is required!' check, then re-wrapped); a $nodeId reference points to a node that emitted no message so messageOutput is undefined and later coerced; checkCondition receives a content value that is an array/object (multi-part LLM content) cast with `as string`; an unsupported operation string reaches the switch in checkCondition.
Common situations: Editing the condition grid in the UI then deploying untested; renaming or deleting an upstream sequential node so a $nodeId reference dangles; an upstream LLM returning multimodal/array content that is no longer a plain string; hand-editing the exported chatflow JSON and corrupting the conditionUI array.
Related errors
- Condition must have a predecessor!
- Condition Agent must have a predecessor!
- Agent name is required!
- Agent must have a predecessor!
- Condition function must return a string
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/2080c791283f57e2.
Report an issue: GitHub.