{"record":{"id":"b6d64ccd3f6d5b99","repo":"n8n-io/n8n","slug":"no-rules-defined","errorCode":null,"errorMessage":"No rules defined","messagePattern":"No rules defined","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/ModelSelector/ModelSelector.node.ts","lineNumber":172,"sourceCode":"\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\tconst models = (await this.getInputConnectionData(\n\t\t\tNodeConnectionTypes.AiLanguageModel,\n\t\t\titemIndex,\n\t\t)) as unknown[];\n\n\t\tif (!models || models.length === 0) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'No models connected', {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'No models found in input connections',\n\t\t\t});\n\t\t}\n\t\tmodels.reverse();\n\n\t\tconst rules = this.getNodeParameter('rules.rule', itemIndex, []) as ModeleSelectionRule[];\n\n\t\tif (!rules || rules.length === 0) {\n\t\t\tthrow new NodeOperationError(this.getNode(), 'No rules defined', {\n\t\t\t\titemIndex,\n\t\t\t\tdescription: 'At least one rule must be defined to select a model',\n\t\t\t});\n\t\t}\n\n\t\tfor (let i = 0; i < rules.length; i++) {\n\t\t\tconst rule = rules[i];\n\t\t\tconst modelIndex = rule.modelIndex;\n\n\t\t\tif (modelIndex <= 0 || modelIndex > models.length) {\n\t\t\t\tthrow new NodeOperationError(this.getNode(), `Invalid model index ${modelIndex}`, {\n\t\t\t\t\titemIndex,\n\t\t\t\t\tdescription: `Model index must be between 1 and ${models.length}`,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst conditionsMet = this.getNodeParameter(`rules.rule[${i}].conditions`, itemIndex, false, {\n\t\t\t\textractValue: true,","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/ModelSelector/ModelSelector.node.ts#L154-L190","documentation":"Thrown by ModelSelector.supplyData() when the 'rules.rule' parameter is empty or missing. Rules are how the node decides which connected model to use; without at least one rule the selection logic has nothing to evaluate and cannot return a model.","triggerScenarios":"this.getNodeParameter('rules.rule', itemIndex, []) resolves to an empty array (or null/undefined), and the guard `if (!rules || rules.length === 0)` throws. Fires when the user has not added any selection rules in the node UI.","commonSituations":"New ModelSelector node left with default (empty) rules; rules parameter accidentally cleared by a workflow import/migration; user expects a default model but none is defined.","solutions":["Open the ModelSelector node and add at least one rule mapping a condition to a model index.","If loading the workflow from JSON, ensure the rules.rule array is populated before execution.","Pair each rule's modelIndex with a connected model (1-based)."],"exampleFix":"// before: parameters.rules.rule = []\n// after: parameters.rules.rule = [{ modelIndex: 1, conditions: { ... } }]","handlingStrategy":"validation","validationCode":"const rules = this.getNodeParameter('rules.rule', itemIndex, []);\nif (!Array.isArray(rules) || rules.length === 0) throw new Error('Define at least one rule');","typeGuard":"function hasRules(r): r is ModeleSelectionRule[] { return Array.isArray(r) && r.length > 0; }","tryCatchPattern":null,"preventionTips":["Always add at least one selection rule when configuring ModelSelector.","Validate imported workflow JSON includes a non-empty rules.rule array.","Treat an empty rules array as a configuration error in pre-execution checks."],"tags":["model-selector","rules","config","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}