Problem in node 'Question and Answer Chain' - message.toJSON is not a function

Describe the problem/error/question

After I upgraded from n8n Version 1.28.0 (docker pull n8nio/n8n:1.28.0) to n8n Version 1.29.1 (docker pull n8nio/n8n:latest), I began to see the following error message when I execute the “Question and Answer Chain” node. I’ve installed an instance of n8n Version 1.28.0 and copied and pasted the same nodes and do not have this issue.

The original error message was the following:

image

I have recreated the nodes from scratch (not copying and pasting from previous workflows) and now I have a different error message on the “Question and Answer Chain” node.

image

I am not sure if I should be posting these types of questions here (n8n community) or GitHub. I have also put it on the N8N GitHub issues section. Question and Answer Chain - Error in sub-node ‘Embeddings OpenAI’ · Issue #8731 · n8n-io/n8n · GitHub. Sorry for duplicating the postings.

What is the error message (if any)?

Problem in node ‘Question and Answer Chain‘

message.toJSON is not a function

Please share your workflow

{
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “1218ccc15068a4d1b900507e0ec24eee43a2b4459048f30dcc1e224c5eb5ed39”
},
“nodes”: [
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “bc1197dc-b8f2-4afc-8a9a-d36f78b2a1c4”,
“name”: “input”,
“value”: “”,
“type”: “string”
}
]
},
“options”: {}
},
“id”: “e22f5595-9577-4ac6-8f05-8429833f0405”,
“name”: “Content”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.3,
“position”: [
-280,
280
]
},
{
“parameters”: {},
“id”: “61b18b36-ef45-4798-85de-c0497a6c99e0”,
“name”: “When clicking "Test workflow"”,
“type”: “n8n-nodes-base.manualTrigger”,
“typeVersion”: 1,
“position”: [
440,
280
]
},
{
“parameters”: {
“mode”: “insert”,
“memoryKey”: “memory”,
“clearStore”: true
},
“id”: “0e2fb0b4-74b2-49c0-9adb-28dd1cbbf50b”,
“name”: “In-Memory Vector Store”,
“type”: “@n8n/n8n-nodes-langchain.vectorStoreInMemory”,
“typeVersion”: 1,
“position”: [
-60,
280
]
},
{
“parameters”: {
“options”: {}
},
“id”: “bf5eac84-6ef9-4bef-8f8f-497411dc7548”,
“name”: “Default Data Loader”,
“type”: “@n8n/n8n-nodes-langchain.documentDefaultDataLoader”,
“typeVersion”: 1,
“position”: [
120,
460
]
},
{
“parameters”: {
“chunkOverlap”: 20
},
“id”: “3b79d50e-772b-473b-9354-16ce410ecc76”,
“name”: “Recursive Character Text Splitter”,
“type”: “@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter”,
“typeVersion”: 1,
“position”: [
40,
640
]
},
{
“parameters”: {
“modelName”: “”,
“options”: {
“endpointUrl”: “http://192.168.0.12:8081/embed
}
},
“id”: “6edea19d-1efc-46a2-8a91-fbce3270a555”,
“name”: “Embeddings HuggingFace Inference”,
“type”: “@n8n/n8n-nodes-langchain.embeddingsHuggingFaceInference”,
“typeVersion”: 1,
“position”: [
-20,
460
],
“credentials”: {
“huggingFaceApi”: {
“id”: “yEkAAMQyIcOGb2yM”,
“name”: “HuggingFaceApi account”
}
}
},
{
“parameters”: {
“assignments”: {
“assignments”: [
{
“id”: “995cf2c9-3766-4a49-a343-4407aece3504”,
“name”: “input”,
“value”: “You are a senior content curator that excels at summarizing content and creating tags for the content so that you can use them later to pull in relevant content. Create a summary in 100 words and create the ten most relevant tags associated with this content.|The output should be a markdown code snippet formatted in the following schema without json or ```:{ "Summary": string // Summary of the review in paragraph format "tags": array // Put the tags into a JSON array}”,
“type”: “string”
}
]
},
“options”: {}
},
“id”: “4bd5b46b-f33c-4cb3-977b-eeb488ea32d1”,
“name”: “Prompt”,
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.3,
“position”: [
660,
280
]
},
{
“parameters”: {
“query”: “={{ $json.input }}”
},
“id”: “12778a07-ba1a-4602-9970-9468f54aef85”,
“name”: “Question and Answer Chain”,
“type”: “@n8n/n8n-nodes-langchain.chainRetrievalQa”,
“typeVersion”: 1.2,
“position”: [
860,
280
]
},
{
“parameters”: {
“model”: “mistral:latest”,
“options”: {
“temperature”: 0
}
},
“id”: “68eae7b5-e7bf-4092-b418-76093797be2b”,
“name”: “Ollama Model”,
“type”: “@n8n/n8n-nodes-langchain.lmOllama”,
“typeVersion”: 1,
“position”: [
860,
500
],
“credentials”: {
“ollamaApi”: {
“id”: “h2lvc9JQTFDvXsf2”,
“name”: “Ollama account”
}
}
},
{
“parameters”: {},
“id”: “273cbfd8-099e-4b80-99bd-912d2508413b”,
“name”: “Vector Store Retriever”,
“type”: “@n8n/n8n-nodes-langchain.retrieverVectorStore”,
“typeVersion”: 1,
“position”: [
1060,
500
]
},
{
“parameters”: {
“memoryKey”: “memory”
},
“id”: “63a2caa9-6c06-444f-b610-b9e2281974af”,
“name”: “In-Memory Vector Store1”,
“type”: “@n8n/n8n-nodes-langchain.vectorStoreInMemory”,
“typeVersion”: 1,
“position”: [
960,
660
]
},
{
“parameters”: {
“modelName”: “”,
“options”: {
“endpointUrl”: “http://192.168.0.12:8081/embed
}
},
“id”: “421c3718-dbf0-40cb-8418-61ab7cbecc60”,
“name”: “Embeddings HuggingFace Inference1”,
“type”: “@n8n/n8n-nodes-langchain.embeddingsHuggingFaceInference”,
“typeVersion”: 1,
“position”: [
900,
840
],
“credentials”: {
“huggingFaceApi”: {
“id”: “yEkAAMQyIcOGb2yM”,
“name”: “HuggingFaceApi account”
}
}
}
],
“connections”: {
“Content”: {
“main”: [
[
{
“node”: “In-Memory Vector Store”,
“type”: “main”,
“index”: 0
}
]
]
},
“When clicking "Test workflow"”: {
“main”: [
[
{
“node”: “Prompt”,
“type”: “main”,
“index”: 0
}
]
]
},
“Default Data Loader”: {
“ai_document”: [
[
{
“node”: “In-Memory Vector Store”,
“type”: “ai_document”,
“index”: 0
}
]
]
},
“Recursive Character Text Splitter”: {
“ai_textSplitter”: [
[
{
“node”: “Default Data Loader”,
“type”: “ai_textSplitter”,
“index”: 0
}
]
]
},
“Embeddings HuggingFace Inference”: {
“ai_embedding”: [
[
{
“node”: “In-Memory Vector Store”,
“type”: “ai_embedding”,
“index”: 0
}
]
]
},
“Prompt”: {
“main”: [
[
{
“node”: “Question and Answer Chain”,
“type”: “main”,
“index”: 0
}
]
]
},
“Ollama Model”: {
“ai_languageModel”: [
[
{
“node”: “Question and Answer Chain”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Vector Store Retriever”: {
“ai_retriever”: [
[
{
“node”: “Question and Answer Chain”,
“type”: “ai_retriever”,
“index”: 0
}
]
]
},
“In-Memory Vector Store1”: {
“ai_vectorStore”: [
[
{
“node”: “Vector Store Retriever”,
“type”: “ai_vectorStore”,
“index”: 0
}
]
]
},
“Embeddings HuggingFace Inference1”: {
“ai_embedding”: [
[
{
“node”: “In-Memory Vector Store1”,
“type”: “ai_embedding”,
“index”: 0
}
]
]
}
},
“pinData”: {}
}

Share the output returned by the last node

1 item

ERROR: message.toJSON is not a function

Details

Stack

TypeError: message.toJSON is not a function
    at /usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/utils/logWrapper.js:168:73
    at Array.map (<anonymous>)
    at Proxy.connectionType (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/utils/logWrapper.js:168:48)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Proxy._generateUncached (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/node_modules/langchain/node_modules/@langchain/core/dist/language_models/llms.cjs:138:22)
    at LLMChain._call (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/node_modules/langchain/dist/chains/llm_chain.cjs:157:37)
    at LLMChain.call (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/node_modules/langchain/dist/chains/base.cjs:120:28)
    at StuffDocumentsChain._call (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/node_modules/langchain/dist/chains/combine_docs_chain.cjs:62:24)
    at StuffDocumentsChain.call (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/node_modules/langchain/dist/chains/base.cjs:120:28)
    at RetrievalQAChain._call (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/node_modules/langchain/dist/chains/retrieval_qa.cjs:81:24)
    at RetrievalQAChain.call (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/node_modules/langchain/dist/chains/base.cjs:120:28)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/nodes/chains/ChainRetrievalQA/ChainRetrievalQa.node.js:104:30)
    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:730:19)
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:662:53
    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1064:20

Question and Answer Chain

Test step

Parameters


Docs

Save time with an example of how this node works

Query

Fixed

Expression

{{ $json.input }}

You are a senior content curator that excels at summarizing content and creating tags for the content so that you can use them later to pull in relevant content. Create a summary in 100 words and create the ten most relevant tags associated with this content.|The output should be a markdown code snippet formatted in the following schema without json or ```:{ “Summary”: string // Summary of the review in paragraph format “tags”: array // Put the tags into a JSON array}

I wish this node would…

Problem in node ‘Question and Answer Chain‘

message.toJSON is not a function

Information on your n8n setup

  • **n8n version:**1.29.1
  • **Database (default: SQLite):**SQLite
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**own
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):**Docker
  • **Operating system:**Ubuntu 22.04 LTS

It happen to me since last friday update also. same node (Q&A) and same issue message.toJSON is not a function. I had try to move to default data loader and other ideas and same issue.

Hey @jfang,

This was fixed in 1.30.1 so an upgrade should get it working, I have also replied to your GitHub issue with the same information.

Generally opening the same issue in 2 places is going to create more work so it would be handy if you could only open the issue in one location, I would recommend here if you want the most eyes on it.

2 Likes

Thank you. I appreciate your tip.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.