n8n-io/n8n · error
SWITCH_WRONG_RULES_KEY
SWITCH_WRONG_RULES_KEY
Error message
${nodeRef} uses 'rules.rules' but the Switch node expects 'rules.values'. Rename the inner key from 'rules' to 'values'. What it means
Error-level validator issue (code SWITCH_WRONG_RULES_KEY) emitted when a Switch node's parameters.rules object has a nested 'rules' key but no 'values' key. The Switch node expects rules.values[]; using rules.rules (a common LLM mistake) will be silently ignored at runtime, so the validator catches the misnaming explicitly.
Source
Thrown at packages/@n8n/workflow-sdk/src/workflow-builder/plugins/validators/filter-node-validator.ts:113
// IF and Filter nodes: conditions is directly on params
const conditions = params.conditions as Record<string, unknown> | undefined;
if (
conditions &&
typeof conditions === 'object' &&
('conditions' in conditions || 'options' in conditions || 'combinator' in conditions)
) {
issues.push(
...validateFilterValue(conditions, nodeRef, 'conditions', displayName, origForWarning),
);
}
// Switch node: conditions are nested inside rules.values[].conditions
const rules = params.rules as Record<string, unknown> | undefined;
if (rules && typeof rules === 'object') {
// Check for wrong key name (common LLM mistake: rules.rules instead of rules.values)
if ('rules' in rules && !('values' in rules)) {
issues.push({
code: 'SWITCH_WRONG_RULES_KEY',
message: `${nodeRef} uses 'rules.rules' but the Switch node expects 'rules.values'. Rename the inner key from 'rules' to 'values'.`,
severity: 'error',
nodeName: displayName,
originalName: origForWarning,
parameterPath: 'rules',
});
}
// Validate filter values inside each rule
const values = (rules.values ?? rules.rules) as Array<Record<string, unknown>> | undefined;
if (Array.isArray(values)) {
for (let i = 0; i < values.length; i++) {
const rule = values[i];
const ruleConditions = rule?.conditions as Record<string, unknown> | undefined;
if (
ruleConditions &&
typeof ruleConditions === 'object' &&
'conditions' in ruleConditionsView on GitHub (pinned to 5ac6606e81)
Solutions
- Rename the inner key from 'rules' to 'values' inside parameters.rules.
- Confirm rules.values is an array of rule objects.
- Re-run the validator to confirm the error clears.
Example fix
// before
switchNode({ rules: { rules: [...] } })
// after
switchNode({ rules: { values: [...] } }) Defensive patterns
Strategy: validation
Validate before calling
const rules = params.rules;
if (rules && typeof rules === 'object' && 'rules' in rules && !('values' in rules)) {
// error: rename inner 'rules' to 'values'
} Prevention
- Use rules.values[] for the Switch node — never rules.rules[].
- Cross-check generated switch config against the Switch node schema.
- Run the filter-node validator (which covers Switch rules) before saving.
When it happens
Trigger: Writing a Switch node with parameters: { rules: { rules: [...] } } instead of { rules: { values: [...] } }.
Common situations: LLM/code-generated switch config that mirrors the outer key name; copy-paste error; misunderstanding the Switch node schema.
Related errors
- FILTER_MISSING_OPTIONS
- FILTER_MISSING_CONDITIONS
- FILTER_MISSING_COMBINATOR
- No rules defined
- Invalid model index ${modelIndex}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/a0adee84215beb93.
Report an issue: GitHub.