{"record":{"id":"a0adee84215beb93","repo":"n8n-io/n8n","slug":"switch-wrong-rules-key","errorCode":"SWITCH_WRONG_RULES_KEY","errorMessage":"${nodeRef} uses 'rules.rules' but the Switch node expects 'rules.values'. Rename the inner key from 'rules' to 'values'.","messagePattern":"(.+?) uses 'rules\\.rules' but the Switch node expects 'rules\\.values'\\. Rename the inner key from 'rules' to 'values'\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/workflow-sdk/src/workflow-builder/plugins/validators/filter-node-validator.ts","lineNumber":113,"sourceCode":"\t\t// IF and Filter nodes: conditions is directly on params\n\t\tconst conditions = params.conditions as Record<string, unknown> | undefined;\n\t\tif (\n\t\t\tconditions &&\n\t\t\ttypeof conditions === 'object' &&\n\t\t\t('conditions' in conditions || 'options' in conditions || 'combinator' in conditions)\n\t\t) {\n\t\t\tissues.push(\n\t\t\t\t...validateFilterValue(conditions, nodeRef, 'conditions', displayName, origForWarning),\n\t\t\t);\n\t\t}\n\n\t\t// Switch node: conditions are nested inside rules.values[].conditions\n\t\tconst rules = params.rules as Record<string, unknown> | undefined;\n\t\tif (rules && typeof rules === 'object') {\n\t\t\t// Check for wrong key name (common LLM mistake: rules.rules instead of rules.values)\n\t\t\tif ('rules' in rules && !('values' in rules)) {\n\t\t\t\tissues.push({\n\t\t\t\t\tcode: 'SWITCH_WRONG_RULES_KEY',\n\t\t\t\t\tmessage: `${nodeRef} uses 'rules.rules' but the Switch node expects 'rules.values'. Rename the inner key from 'rules' to 'values'.`,\n\t\t\t\t\tseverity: 'error',\n\t\t\t\t\tnodeName: displayName,\n\t\t\t\t\toriginalName: origForWarning,\n\t\t\t\t\tparameterPath: 'rules',\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Validate filter values inside each rule\n\t\t\tconst values = (rules.values ?? rules.rules) as Array<Record<string, unknown>> | undefined;\n\t\t\tif (Array.isArray(values)) {\n\t\t\t\tfor (let i = 0; i < values.length; i++) {\n\t\t\t\t\tconst rule = values[i];\n\t\t\t\t\tconst ruleConditions = rule?.conditions as Record<string, unknown> | undefined;\n\t\t\t\t\tif (\n\t\t\t\t\t\truleConditions &&\n\t\t\t\t\t\ttypeof ruleConditions === 'object' &&\n\t\t\t\t\t\t'conditions' in ruleConditions","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder/plugins/validators/filter-node-validator.ts#L95-L131","documentation":"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.","triggerScenarios":"Writing a Switch node with parameters: { rules: { rules: [...] } } instead of { rules: { values: [...] } }.","commonSituations":"LLM/code-generated switch config that mirrors the outer key name; copy-paste error; misunderstanding the Switch node schema.","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."],"exampleFix":"// before\nswitchNode({ rules: { rules: [...] } })\n// after\nswitchNode({ rules: { values: [...] } })","handlingStrategy":"validation","validationCode":"const rules = params.rules;\nif (rules && typeof rules === 'object' && 'rules' in rules && !('values' in rules)) {\n  // error: rename inner 'rules' to 'values'\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["switch","validator","rules","node-config","key-name"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}