{"record":{"id":"da9e83f733a6959e","repo":"n8n-io/n8n","slug":"unsafe-memory-session-key-expression","errorCode":"UNSAFE_MEMORY_SESSION_KEY_EXPRESSION","errorMessage":"'${nodeName}' parameter '${parameterPath}' uses $json in an AI memory subnode session key. Use an explicit node reference such as nodeJson(trigger, 'message.chat.id') or $('Trigger').item.json.message.chat.id.","messagePattern":"'(.+?)' parameter '(.+?)' uses \\$json in an AI memory subnode session key\\. Use an explicit node reference such as nodeJson\\(trigger, 'message\\.chat\\.id'\\) or \\$\\('Trigger'\\)\\.item\\.json\\.message\\.chat\\.id\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/workflow-sdk/src/workflow-builder/plugins/validators/memory-session-key-validator.ts","lineNumber":40,"sourceCode":"function isMemorySubnode(node: NodeInstance<string, string, unknown>): boolean {\n\treturn hasSubnodeType(node) && node._subnodeType === MEMORY_SUBNODE_TYPE;\n}\n\nfunction usesFromInputSessionId(parameters: Record<string, unknown>): boolean {\n\treturn parameters.sessionIdType === 'fromInput';\n}\n\nfunction isUnsafeSessionExpression(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.includes('$json') &&\n\t\t(value.startsWith('=') || value.includes('{{'))\n\t);\n}\n\nfunction createIssue(nodeName: string, parameterPath: string): ValidationIssue {\n\treturn {\n\t\tcode: 'UNSAFE_MEMORY_SESSION_KEY_EXPRESSION',\n\t\tmessage: `'${nodeName}' parameter '${parameterPath}' uses $json in an AI memory subnode session key. Use an explicit node reference such as nodeJson(trigger, 'message.chat.id') or $('Trigger').item.json.message.chat.id.`,\n\t\tseverity: 'error',\n\t\tviolationLevel: 'major',\n\t\tnodeName,\n\t\tparameterPath,\n\t};\n}\n\n/**\n * Validator for AI memory subnode session key expressions.\n *\n * Checks for:\n * - `$json` in manually configured memory session keys\n * - Does not flag Chat Trigger's `fromInput` memory mode\n */\nexport const memorySessionKeyValidator: ValidatorPlugin = {\n\tid: 'core:memory-session-key',\n\tname: 'Memory Session Key Validator',","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder/plugins/validators/memory-session-key-validator.ts#L22-L58","documentation":"Error \"'${nodeName}' parameter '${parameterPath}' uses $json in an AI memory subnode session key. Use an explicit node reference such as nodeJson(trigger, 'message.chat.id') or $('Trigger').item.json.message.chat.id.\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/workflow-sdk/src/workflow-builder/plugins/validators/memory-session-key-validator.ts:40 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}