n8n-io/n8n · error · NodeOperationError
No rules defined
Error message
No rules defined
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/ModelSelector/ModelSelector.node.ts:172
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
const models = (await this.getInputConnectionData(
NodeConnectionTypes.AiLanguageModel,
itemIndex,
)) as unknown[];
if (!models || models.length === 0) {
throw new NodeOperationError(this.getNode(), 'No models connected', {
itemIndex,
description: 'No models found in input connections',
});
}
models.reverse();
const rules = this.getNodeParameter('rules.rule', itemIndex, []) as ModeleSelectionRule[];
if (!rules || rules.length === 0) {
throw new NodeOperationError(this.getNode(), 'No rules defined', {
itemIndex,
description: 'At least one rule must be defined to select a model',
});
}
for (let i = 0; i < rules.length; i++) {
const rule = rules[i];
const modelIndex = rule.modelIndex;
if (modelIndex <= 0 || modelIndex > models.length) {
throw new NodeOperationError(this.getNode(), `Invalid model index ${modelIndex}`, {
itemIndex,
description: `Model index must be between 1 and ${models.length}`,
});
}
const conditionsMet = this.getNodeParameter(`rules.rule[${i}].conditions`, itemIndex, false, {
extractValue: true,View on GitHub (pinned to 5ac6606e81)
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).
Example fix
// before: parameters.rules.rule = []
// after: parameters.rules.rule = [{ modelIndex: 1, conditions: { ... } }] Defensive patterns
Strategy: validation
Validate before calling
const rules = this.getNodeParameter('rules.rule', itemIndex, []);
if (!Array.isArray(rules) || rules.length === 0) throw new Error('Define at least one rule'); Type guard
function hasRules(r): r is ModeleSelectionRule[] { return Array.isArray(r) && r.length > 0; } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid model index ${modelIndex}
- No matching rule found
- MCP server "${cfg.name}": exactly one of "url" or "command"
- MCP server "${cfg.name}": provide either "url" or "command",
- Unknown agents module: "${moduleName}". ${validTokens ? `Val
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/b6d64ccd3f6d5b99.
Report an issue: GitHub.