AI-generated IF nodes patched to stop always returning true
A fix ensures AI-generated IF nodes in workflows evaluate correctly by applying missing default values and providing AI systems with a template for proper node structure.
AI-generated workflows containing IF nodes were silently breaking — the conditional logic would always resolve to true, regardless of the actual data flowing through. This happened because AI systems often generated nodes without critical required fields like combinator and options. Without these fields, the condition evaluation logic fell back to treating the raw condition data as truthy values.
The fix works in two directions. First, when workflows are loaded, the system now patches any malformed filter conditions by injecting the missing defaults — applying the same logic the UI uses when a user opens a broken node. Second, a builder hint was added to the IF node type that provides AI systems with an explicit template showing exactly what fields are required and how they should be structured.
In the workflow engine, filter parameters now receive default values for combinator ("and"), options with caseSensitive, leftValue, typeValidation, and version — ensuring consistent behavior whether nodes were hand-crafted or AI-generated.
This resolves AI-2334 and ensures AI-generated automations behave as intended.
View Original GitHub Description
Summary
This PR fixes a bug in AI generated workflows where the AI needs to generate an n8n-nodes-base.if node.
Due to missing informations to the AI, the node is generated with a broken structure, but will still run, e.g.:
{
"parameters": {
"conditions": {
"conditions": [
{
"id": "rain-check",
"leftValue": "={{ $json.hasRain }}",
"operator": {
"type": "boolean",
"operation": "true"
},
"rightValue": ""
}
]
},
"options": {}
},
"id": "aa3f0c98-2f23-478d-981d-4dbb7e6693e4",
"name": "Is Rain Predicted?",
"type": "n8n-nodes-base.if",
"typeVersion": 2.3,
"position": [
912,
208
]
}
When firing, though, it will always fire true, since the function extractValueFilter tries to extract the value of the conditions filter. since this filter is missing the field combinator, the function isFilterValue will return false, and the extracted value of this filter will be its own raw value, that will then evaluate as trueish
The way the fix is implemented is twofold: first, it applies the same patching that the UI does when the user opens such a misformed node, applying the default values where missing. Also, adds hints for the AI to create correctly formed nodes.
Related Linear tickets, Github issues, and Community forum posts
Review / Merge checklist
- PR title and summary are descriptive. (conventions) <!-- **Remember, the title automatically goes into the changelog. Use `(no-changelog)` otherwise.** -->
- Docs updated or follow-up ticket created.
- Tests included. <!-- A bug is not considered fixed, unless a test is added to prevent it from happening again. A feature is not complete without tests. -->
- PR Labeled with
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)