After reviewing the first five pages of Google search results, consulting with GPT for several hours, and finding no resolution, it appears this is a bug.
Is there any method to "clean up" the code within another node?
I attempted to circumvent the bug by using the Baserow database as an intermediary. Initially, I saved the text there and then retrieved it. However, intermittently, callin.io still identifies the JSON as invalid.
All the data presented below originates from the same request.
ERROR: JSON parameter need to be an valid JSON details:
NodeOperationError: JSON parameter need to be an valid JSON
at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:1070:35)
at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:652:51)
at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:596:68
at processTicksAndRejections (node:internal/process/task_queues:96:5)
JSON that is causing the problem. According to the validators, it has the correct format:
[
{
"id":
1,
"order":
"1.00000000000000000000",
"Wiadomosc":
"wymień listę 10 komedii lat 80",
"Odpowiedz":
"The Breakfast Club 1985 Ferris Buellers Day Off 1986 Ghostbusters 1984 Airplane 1980 The Princess Bride 1987 Trading Places 1983 National Lampoons Vacation 1983 Caddyshack 1980 The Naked Gun From the Files of Police Squad 1988 This Is Spinal Tap 1984"
}
]
The entire core communication between the upper weather branch and the final Signal node has been functioning without issues for several months.
After integrating the OpenAI node, the Signal node occasionally fails to parse the code, resulting in a JSON error.
If anyone has knowledge of an effective method to call a "check message" request, I would be grateful to learn.
BTW
I am encountering the same problem with this setup; the same error appears with every few responses. This leads me to believe the issue might stem from the OpenAI output.
Typically,
can be fixed by using JSON.stringify()
on the incoming data within the parameter input.
Hello, thanks for getting back to me.
The entire workflow functions correctly for straightforward responses. The bot typically communicates via Signal, with or without a code node. However, when I input a request like “list 10 movies of the 80s,” a JSON error occurs, and the message isn't delivered.
I've implemented the following code in the node preceding the output, but the same error persists:
const inputData = JSON.stringify(items[0].json);
const outputData = inputData;
return {
json: {
outputData: outputData
}
};
In the subsequent node:
const inputData = JSON.parse(items[0].json.outputData);
const outputData = inputData.message.content;
return {
json: {
outputData: outputData
}
};
Here is the JSON that callin.io flags as "incorrect":
[
{
"outputData":"Oto 10 losowych filmów z lat 80: 1. "Krzyk" (1984) 2. "Czas apokalipsy" (1986) 3. "Indiana Jones i Świątynia Zagłady" (1984) 4. "Top Gun" (1986) 5. "Powrót do przyszłości" (1985) 6. "Pluton" (1986) 7. "Gremliny" (1984) 8. "Omen III: Ostatnie Starcie" (1981) 9. "Scarface" (1983) 10. "Poltergeist" (1982)"
}
]
Could you please advise on how to resolve this?
Hey,
That JSON appears to be invalid. You have unescaped "
characters within your data, which will lead to problems.
Could you share your workflow JSON so we can examine it more closely?
Previously, I attempted to resolve this using JavaScript code generated by GPT. I tried replacing double quotes with spaces and removing certain whitespace characters, but unfortunately, it didn't resolve the issue.
Currently, a Schedule node triggers an HTTP Request to the Signald container every 10 seconds to check for new messages. (I'm unsure of alternative methods to trigger this workflow).
An IF node then forwards the entire message if it contains the characters /gpt
.
The subsequent Code node extracts only the "message" part from the received string and removes the /gpt
characters.
The OpenAI node receives the extracted, clean message to perform its task.
The next Code block is for a suggested JSON to string conversion, which creates a string with "content" in the middle.
The final Code block extracts the "content" from this string and passes it to the HTTP Request.
The HTTP Request then sends a message via the Signald API to the Signal messenger.
The issue with JSON seems to occur after the OpenAI node, likely in most scenarios. It's worth noting that this workflow generally functions, but the error appears approximately once every five messages, typically when dealing with lists of items.
Hey,
If this issue only occurs during specific runs, it's likely related to the data. The example you shared appeared invalid, so I suspect similar data might be the cause.
I recommend ensuring that you escape special characters, as this will probably resolve most of the problems.
Please provide the rewritten markdown content.
What special characters are not permitted, or how can I "clear" the data to prevent the error from appearing?
Hello,
In theory, all characters are permitted. However, if your string begins with a " character, it will anticipate the next " character as the end of the string. You would need to escape these characters to ensure valid JSON.
I attempted to resolve the issue by using the Code node to replace the "
character with a space, but this did not resolve the problem.
Hey,
You won't want to replace all of them. Have you run your output through a JSON linter to see if it shows as valid?
Please provide the rewritten markdown content *it should be in the markdown format.
Let's say I have an Input node preceding the final node that transmits data to Signal.
If this Input node contains, for instance, plain text or weather information, there's no issue, and Signal successfully delivers all messages.
However, if I substitute the Input node with an OpenAI node, the Signal node occasionally returns an error in its responses.
Even inserting a Code node between the OpenAI node and the Signal node, with code designed to remove quotation marks from the response, doesn't resolve the problem. This modification doesn't impact the message structure within the Signal node.
Hi there,
Could you please share the output from the node that's encountering the error, along with the content it's attempting to post? Based on the node data, it appears many users are utilizing the OpenAI node, which might be unrelated to the issue.
Here is the Input JSON data:
1 item
[
{
"id":
"chatcmpl-7P9XV6U1nfdnZ8oez7OU344OsogH",
"object":
"chat.completion",
"created":
1686229225,
"model":
"gpt-3.5-turbo-0301",
"usage":
{
"prompt_tokens":
132,
"completion_tokens":
269,
"total_tokens":
401
},
"choices":
[
{
"message":
{
"role":
"assistant",
"content":
"Cześć rowerowe kanapki! Oto Lily, Twoja ulubiona prezenterka pogody! Więc słuchajcie uważnie - jeśli dzisiaj planujecie jazdę na rowerze, to zdecydowanie polecam założyć ciepłe spodnie i kurtkę w kolorze wiatru (czytaj: szarym) - temperatury spadły do ,, a wiatr nie daje nam spokoju i osiąga prędkości km/h, które poruszają nie tylko Twoje drzewko. Brrr! Instalujcie swoje czapki i rękawiczki, żeby nie spadły z wiatrem! 🌪️ Mam nadzieję, że przetrwacie tę zimną jazdę i patrzcie na jaśniejszą stronę - w końcu przynajmniej nie będziecie się pocić! 💦 No cóż, wybaczcie mi, że musiałem dostarczyć złe wiadomości, ale zobaczymy się jutro o tej samej porze! 😂"
},
"finish_reason":
"stop",
"index":
0
}
]
}
]
Second JSON object:
1 item
[
{
"id":
"chatcmpl-dfg345455v38v3k4FN5f4w54",
"object":
"chat.completion",
"created":
1686142805,
"model":
"gpt-3.5-turbo-0301",
"usage":
{
"prompt_tokens":
149,
"completion_tokens":
188,
"total_tokens":
337
},
"choices":
[
{
"message":
{
"role":
"assistant",
"content":
"Cześć wszystkim! Tutaj Lily z prognozą pogody. Dzisiaj o godzinie 15:00 jest pochmurnie, ale rowerzyści nie będą się martwić. Temperatura wynosi 21 stopni, więc lekkie koszulki i spodenki będą idealne. Wiatr jest lekki, więc warto zabrać kurtkę w razie zmiany warunków na drodze. Nie zapomnijcie o kasku i zabierzcie ze sobą butelkę wody! 💦 No i przede wszystkim, nie zapominajcie o uśmiechu na twarzy! 😁 Do zobaczenia jutro o tej samej porze! 🚴♀️🚴♂️☁️"
},
"finish_reason":
"stop",
"index":
0
}
]
}
]
Another JSON object:
[
{
"id":
"chatcmpl-45g34h567xaqmNZcKtg45g45",
"object":
"chat.completion",
"created":
1686198604,
"model":
"gpt-3.5-turbo-0301",
"usage":
{
"prompt_tokens":
146,
"completion_tokens":
345,
"total_tokens":
491
},
"choices":
[
{
"message":
{
"role":
"assistant",
"content":
"Witajcie Kochani! Oto Ashley - wasza ulubiona prezenterka pogody! Patrzę przez okno i...o matko, chyba zostaliśmy zapomniani przez słońce! Dziś jest pochmurnie i mało przyjemnie, ale nie dajcie się zniechęcić. Przygotujcie swoje rowery, bo wsiadamy na nie i jedziemy! Na pierwszy rzut oka temperatura wynosi 12.26 stopni Celsjusza, ale brrr...wydaje mi się, że jest o wiele chłodniej! Zdecydowanie polecam ciepłą bluzę, kurtkę, rękawiczki i oczywiście...czepek pod kask. Nie chcecie przecież złapać przeziębienia i kolejnego dnia spędzić w łóżku! A co z wiatrem? Na szczęście chłodzi nas on tylko trochę, dzisiaj przewidywana prędkość to 3.09 km/h, ale uważajcie na porywy! Mniejsza o to, jak się ubierzecie - ważne, żebyście ruszyli do przodu! A na zakończenie... 🤪 widzimy się jutro o tej samej porze! Trzymajcie się, moi śmiałkowie, i róbcie to, co lubicie najbardziej!"
},
"finish_reason":
"stop",
"index":
0
}
]
}
]
HTTP node JSON:
{"base64_attachments":["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4QBsRXhpZgAASUkqAAgAAAADADEBAgAHAAAAMgAAABICAwACAAAAAgACAGmHBAABAAAAOgAAAAA"], "message": "[Pogodynka] {{ $node.OpenAI1.json.choices[0].message.content }}" , "number": "+3123456789", "recipients": ["group.345645FzUWRVRkRNbFVCUDVkeVZSaG9kdW1td534534534UvaFh5bz0="]}
However, it functions intermittently:
Working JSON:
1 item
[
{
"id":
"chatcmpl-34r2345f243E2e4dLKIMpwerf34f",
"object":
"chat.completion",
"created":
1685939422,
"model":
"gpt-3.5-turbo-0301",
"usage":
{
"prompt_tokens":
129,
"completion_tokens":
229,
"total_tokens":
358
},
"choices":
[
{
"message":
{
"role":
"assistant",
"content":
"Cześć wszystkim słuchaczom! Oto najlepsza prezenterka pogody pod słońcem - Ashley! Dzisiaj jest godzina 7:30 rano, więc czas na małą poranną prognozę. No więc bierzcie rowery i jedziemy! Temperatura wynosi obecnie -5 stopni Celsjusza, z wiatrem wiejącym z prędkością 25 km/h. Radzę założyć spodnie, kurtkę, rękawiczki, czapkę i oczywiście tarcze na koła rowerowe. Zakładam, że wyglądacie już teraz jak prawdziwi mistrzowie ekstremalnych sportów zimowych! 😜 Więc jedziemy z pełną parą! Zobaczymy się jutro o tej samej porze, a ja już zaczynam się szykować do kolejnej wesołej prognozy! 😄"
},
"finish_reason":
"stop",
"index":
0
}
]
}
]
Another working example from the screenshot above:
1 item
[
{
"id":
"chatcmpl-234523trswVBEjQV17erfwgf345",
"object":
"chat.completion",
"created":
1685680202,
"model":
"gpt-3.5-turbo-0301",
"usage":
{
"prompt_tokens":
146,
"completion_tokens":
211,
"total_tokens":
357
},
"choices":
[
{
"message":
{
"role":
"assistant",
"content":
"🕡Dobrego poranka! Oto przewidywana pogoda o godzinie 06:30: duże zachmurzenie, 10.48 stopni celcjusza i 4.63 km/h wiatru 💨 Dla rowerzystów polecam dodać do swojego stroju ciepłą kurtkę i ochraniacze na uszy, aby uniknąć zamarznięcia i być przygotowanym na każdą okoliczność! ❄️ Ale nie martwcie się, bo przynajmniej będziecie mieli wiatr we włosach, kiedy będziecie pędzić w dół na rowerze 🚴♂️🚴♀️🌬️ Zobaczymy się jutro o tej samej porze z jeszcze więcej pozytywnych wieści! 😴👋"
},
"finish_reason":
"stop",
"index":
0
}
]
}
]