Strange invalid JSON error

I have a workflow triggered by incoming emails (in Outlook). the 2nd node in the flow is an edit fields, to get and set values of the email vital info, to be later stored in an external Supabase. The Edit Fields node then connects to a Crypto node.

Most executions work properly, but I got a failed execution on a “The ‘JSON Output’ in item 0 contains invalid JSON” error. Looks like quotation marks were for some reason added to the errorFlowSendDateTime data, which broke the JSON structure. I’m not sure how/why this happened, as the original input does not have these quotations.

What is the error message (if any)?

The ‘JSON Output’ in item 0 contains invalid JSON
{ “errorFlowSender”: “[email protected]”, “errorFlowSubject”: " New Assignment | Translation + Editing | 2025_18430 CI-018YTWN -20250328-154022 | HE ▸ EN-US", “errorFlowSendDateTime”: “2025-03-“28T22”:“22”:37Z”, “errorFlowN8nExecutionID”: “1083” }; Original input: { “errorFlowSender”: “[email protected]”, “errorFlowSubject”: " New Assignment | Translation + Editing | 2025_18430 CI-018YTWN -20250328-154022 | HE ▸ EN-US", “errorFlowSendDateTime”: “2025-03-28T22:22:37Z”, “errorFlowN8nExecutionID”: “1083” }

Here are the first 3 nodes of the flow:
{
“nodes”: [
{
“parameters”: {
“pollTimes”: {
“item”: [
{
“mode”: “everyX”,
“value”: 10,
“unit”: “minutes”
}
]
},
“output”: “raw”,
“filters”: {
“foldersToInclude”: [
“AQMkAGM3MGE5NzFjLWU3MmMtNDVlMS05ZmNkLTY2ADhkMzA2NzRkYWQALgAAA2PYWihIdnJHgVqawr3RzcEBAEPIwGsDQypPkhNI7ssYblEAAAIBDAAAAA==”
]
},
“options”: {}
},
“type”: “n8n-nodes-base.microsoftOutlookTrigger”,
“typeVersion”: 1,
“position”: [
-1000,
-540
],
“id”: “85eaaab8-b7fd-4142-8210-0e6b77e0d127”,
“name”: “Microsoft Outlook Trigger”,
“credentials”: {
“microsoftOutlookOAuth2Api”: {
“id”: “dlQmSJbLcbrfP1dd”,
“name”: “[email protected] - Shared Inbox”
}
}
},
{
“parameters”: {
“type”: “SHA256”,
“value”: “={{ $(‘Microsoft Outlook Trigger’).item.json.subject }}{{ $(‘Microsoft Outlook Trigger’).item.json.body.content }}”,
“dataPropertyName”: “messageHash”,
“encoding”: “base64”
},
“type”: “n8n-nodes-base.crypto”,
“typeVersion”: 1,
“position”: [
-300,
-540
],
“id”: “9cef02d5-901a-4df5-8e41-5b3cd1fa5252”,
“name”: “Crypto - Create message hash”
},
{
“parameters”: {
“mode”: “raw”,
“jsonOutput”: “={\n "errorFlowSender": "{{ $json.from.emailAddress.address }}",\n "errorFlowSubject": "{{ $json.subject }}",\n "errorFlowSendDateTime": "{{ $json.receivedDateTime }}",\n"errorFlowN8nExecutionID": "{{ $executionId }}"\n}”,
“options”: {}
},
“type”: “n8n-nodes-base.set”,
“typeVersion”: 3.4,
“position”: [
-560,
-540
],
“id”: “61305d15-9e7e-4a74-9927-dc2c69916204”,
“name”: “Edit Fields”
}
],
“connections”: {
“Microsoft Outlook Trigger”: {
“main”: [
[
{
“node”: “Edit Fields”,
“type”: “main”,
“index”: 0
}
]
]
},
“Crypto - Create message hash”: {
“main”: [

]
},
“Edit Fields”: {
“main”: [
[
{
“node”: “Crypto - Create message hash”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“pinData”: {},
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “98f7f9ddb2c320c93d60209523d27b02dbf8cb34c49250cd009c51434f101b28”
}
}

Information on your n8n setup

  • n8n version: 1.84.1 (cloud)
  • Database (default: SQLite): Supabase
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n cloud
  • Operating system:

Could you post the workflow using the </> button and maybe pinning some data?

Here is how: Google sheet: data is replaced in the existing row instead of adding new row - #8 by Olek

Hi, cant you use JSON.stringify to deal with this?

I’d say rather JSON.parse but I’d need to see the workflow and data to verify. Not sure why quotes are added where they shouldn’t. There can be multiple reasons for this and hence multiple solutions to resolve the issue.

1 Like

you are right. but if the json is invalid for UI to parse its unlikley that JSON.parse can create an object. lets see the workflow

As I wrote initially - the data flowed correctly for most executions (about 1000 so far). I only saw the error on two (unrelated) executions. I don’t want to add something (json.stringify in this case) if I don’t have to.

Hi,

I think its good practice anyway, just accepting anything from the outside is asking for trouble (as you experience in only 2 out of 1000…:slight_smile: Its the same for DB transcations, sometimes there are weird characters. you need to deal with that whether you like it or not

Here’s the flow (first 3 nodes) with content. I wasn’t able to reproduce the error though. As far as I can see the failed executions started with valid datettime values, same as the working executions.

So, in those two failing execution which node caused the problem?

The error appeared in the Edit Fields node. Where/why it was it actually caused? I don’t know. The node seems to work fine most of the time.

For example, the same node failed on this datetime value (added the extra quatations): 2025-03-27T20:35:36Z

But in another execution it worked fine (no extra quotations) on this value: 2025-03-30T08:33:56Z

The value structure seems the same to me. No idea why one broke and another didn’t.

I would take the full failed execution input data and try to replicate it with pinned. most likely theres an illegal character / encoding with any JSON before. If nothing helps try reducing / removing in half’s to see when it starts working (or not). - or just remove everything else than the fields you want to process. in this way you likely find a hint, as there is not much else to go on TBH

1 Like

Could be smth wrong with the JSON builder on n8n side.
Try to switch to “normal” Set use case, where you specify individual fields to set and drag fields from the input.

BTW, $executionID throws an error on my instance. Used documented $execution.id instead.

Appreciated, will continue to monitor and look for clues.
I’m hesitant to try JSON stringify, as I tried it already on the subject line (thinking there was indeed a bad character there), and it broke the node. Maybe I did something wrong, will try again :slight_smile:

Thank you all for the assistance. This is my first post here, and it’s very nice to receive such helpful and fast reactions!

With workflow properly posted and issue described it is easy.

Happy n8ning!

P.S. I updated my post above. Hope this helps.

1 Like

When and if you have your issue resolved, please update this thread with your learnings, to the benefit of the n8n Community.

Also if any of the posts above happen to contain a working solution, please mark it as a :white_check_mark: Solution. This will help future readers that face a similar issue spot the solution. Your future solution post also counts as such if the solution is different from any other posted above.

1 Like

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