{"record":{"id":"8c47d67efd0009d7","repo":"n8n-io/n8n","slug":"onfalse-is-only-available-on-if-nodes-node-t","errorCode":null,"errorMessage":".onFalse() is only available on IF nodes (${NODE_TYPES.IF})","messagePattern":"\\.onFalse\\(\\) is only available on IF nodes \\((.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/workflow-sdk/src/workflow-builder/node-builders/node-builder.ts","lineNumber":332,"sourceCode":"\t\tif (!isIfNodeType(this.type)) {\n\t\t\tthrow new Error(`.onTrue() is only available on IF nodes (${NODE_TYPES.IF})`);\n\t\t}\n\t\tconst builder = new IfElseBuilderImpl<TOutput>(\n\t\t\tthis as unknown as NodeInstance<'n8n-nodes-base.if', string, TOutput>,\n\t\t);\n\t\treturn builder.onTrue(target);\n\t}\n\n\t/**\n\t * Start building an IF branch with the false branch target.\n\t * Only available on IF nodes (n8n-nodes-base.if).\n\t *\n\t * @example\n\t * ifNode.onFalse(falseHandler).onTrue(trueHandler)\n\t */\n\tonFalse(target: IfElseTarget): IfElseBuilder<TOutput> {\n\t\tif (!isIfNodeType(this.type)) {\n\t\t\tthrow new Error(`.onFalse() is only available on IF nodes (${NODE_TYPES.IF})`);\n\t\t}\n\t\tconst builder = new IfElseBuilderImpl<TOutput>(\n\t\t\tthis as unknown as NodeInstance<'n8n-nodes-base.if', string, TOutput>,\n\t\t);\n\t\treturn builder.onFalse(target);\n\t}\n\n\t/**\n\t * Start building a Switch case with a case target.\n\t * Only available on Switch nodes (n8n-nodes-base.switch).\n\t *\n\t * @example\n\t * switchNode.onCase(0, caseA).onCase(1, caseB)\n\t */\n\tonCase(index: number, target: SwitchCaseTarget): SwitchCaseBuilder<TOutput> {\n\t\tif (!isSwitchNodeType(this.type)) {\n\t\t\tthrow new Error(`.onCase() is only available on Switch nodes (${NODE_TYPES.SWITCH})`);\n\t\t}","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder/node-builders/node-builder.ts#L314-L350","documentation":"Thrown by NodeInstanceImpl.onFalse() when isIfNodeType(this.type) is false. Symmetric to onTrue: the false-output branch builder only exists on n8n-nodes-base.if nodes; other node types lack that output port.","triggerScenarios":"Calling someNode.onFalse(handler) on a non-IF node; assuming every node has a 'false' branch.","commonSituations":"Mis-typed node factory call; using a Switch node where an IF was intended; generic branch-building code.","solutions":["Use node('n8n-nodes-base.if', ...) for the node you call .onFalse() on.","For other node types, use the appropriate wiring (.to(), .onCase()).","Narrow with isIfNodeType before invoking onTrue/onFalse."],"exampleFix":"// before\nconst n = node('n8n-nodes-base.code', 'v2', { ... });\nn.onFalse(fallback); // throws\n// after\nconst ifNode = node('n8n-nodes-base.if', 'v1', { ... });\nifNode.onTrue(handler).onFalse(fallback);","handlingStrategy":"type-guard","validationCode":"function assertIfNode(node: NodeInstance): asserts node is NodeInstance<'n8n-nodes-base.if', string, unknown> {\n  if (node.type !== 'n8n-nodes-base.if') {\n    throw new Error(`.onFalse() requires an IF node, got ${node.type}`);\n  }\n}\n\nassertIfNode(myNode);\nmyNode.onFalse(handler);","typeGuard":"import { isIfNodeType } from '@n8n/workflow-sdk';\n\nfunction isIfNode(node: NodeInstance): node is NodeInstance<'n8n-nodes-base.if', string, unknown> {\n  return isIfNodeType(node.type);\n}","tryCatchPattern":null,"preventionTips":["Use node('n8n-nodes-base.if', ...) for any node on which you call .onFalse().","Narrow with isIfNodeType before branch calls.","Keep IF/Switch usage distinct in helper code."],"tags":["runtime","builder","if-node","branching"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}