Error [ERROR: Cannot read properties of undefined (reading 'filter')] with chat and ai agent - This thread has been closed, but it’s definitely not been resolved.
I have exactly the same issue when using the Postgres Chat Memory node connected to Supabase. If I delete all the data in the database, it works. If I then try to use it any time after the first chat, it shows an error which is pretty useless for a chat use case.
{
“errorMessage”: “Cannot read properties of undefined (reading ‘map’)”,
“errorDetails”: {},
“n8nDetails”: {
“n8nVersion”: “1.59.4 (Self Hosted)”,
“binaryDataMode”: “default”,
“stackTrace”: [
“TypeError: Cannot read properties of undefined (reading ‘map’)”,
" at _formatContent (/usr/local/lib/node_modules/n8n/node_modules/@langchain/anthropic/dist/utils/message_inputs.cjs:105:39)“,
" at /usr/local/lib/node_modules/n8n/node_modules/@langchain/anthropic/dist/utils/message_inputs.cjs:224:26”,
" at Array.map ()“,
" at _formatMessagesForAnthropic (/usr/local/lib/node_modules/n8n/node_modules/@langchain/anthropic/dist/utils/message_inputs.cjs:172:52)”,
" at ChatAnthropic._streamResponseChunks (/usr/local/lib/node_modules/n8n/node_modules/@langchain/anthropic/dist/chat_models.cjs:671:87)“,
" at _streamResponseChunks.next ()”,
" at ChatAnthropic._streamIterator (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/language_models/chat_models.cjs:92:34)“,
" at processTicksAndRejections (node:internal/process/task_queues:95:5)”,
" at ChatAnthropic.transform (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:402:9)“,
" at RunnableBinding.transform (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:846:9)”,
" at ToolCallingAgentOutputParser.transform (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:391:26)“,
" at RunnableSequence._streamIterator (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:1219:30)”,
" at RunnableSequence.transform (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:402:9)“,
" at wrapInputForTracing (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:275:30)”,
" at pipeGeneratorWithSetup (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/utils/stream.cjs:260:19)“,
" at RunnableLambda._transformStreamWithConfig (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:296:26)”,
" at RunnableSequence._streamIterator (/usr/local/lib/node_modules/n8n/node_modules/@langchain/core/dist/runnables/base.cjs:1219:30)"
]
}
}