Backup N8N workflows to Github Unexpected end of JSON input [Line 4]

Hi, I’ve seen several posts mention the same workflow with the same error, however none of the threads i’ve read end with a solution, and they are all closed for posting, hence this ‘repeat’ post.

Describe the problem/error/question

I’ve been running this workflow for some time without issue, however recently noticed that it’s been erroring out for a few weeks to a month now.

What is the error message (if any)?

Problem in node ‘isDiffOrNew‘
Unexpected end of JSON input [Line 4]

Please share your workflow

Share the output returned by the last node

The error occurs on run 9 of 9, with the prior 8 having no issues. the entire logged message is as follows:

{  
"__type":  
"$$EventMessageWorkflow",  
"id":"334e7c51-e657-47ea-923ad22105d88712",  
"ts":"2024-04-22T22:26:29.770-04:00",  
"eventName":"n8n.workflow.failed",  
"message":"n8n.workflow.failed",  
"payload":  
{  
"executionId":"334545",  
"success":false,  
"userId":"8e18c06a-afa3-44f5-b611-e2bfe762f0dd",  
"workflowId":"9",  
"isManual":true,  
"workflowName":"Back Up Your n8n Workflows To Github",  
"lastNodeExecuted":"isDiffOrNew",  
"errorNodeType":"n8n-nodes-base.function",  
"errorNodeId":"8",  
"errorMessage":"Unexpected end of JSON input [Line 4]"  
}  
}

The specific workflow it appears to be having an issue with is "workflowId":"9" which just so happens to be the very workflow that is giving errors. As this has been working for 1+ years now, I’m not sure what is suddenly wrong with this workflow. I’ve tried duplicating it and testing the duplicate, and have run into the same issue with copied workflow.

Information on your n8n setup

  • n8n version: Version 1.37.3
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default setting (no custom setting for this value).
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: MacOS 14.4.1 / Docker Desktop v4.29.0 / node version 16.18.1

Hey @craigz,

I think I might need to revisit the worklfow as there is probably a better way to handle it now. The error itself looks like there is something funky in the worklfow json but I am not sure what that would be.

Hi @Jon,

Thanks for looking into this.

For what it’s worth, i downloaded the returned json from the step (it was 1.2MB and n8n wanted nothing to do with displaying it in the output window) and tossed the raw contents at a json validator which found no errors.

hi @Jon,

i ended up exec-ing into the container, and removing all of the files the workflow created.
i then duplicated the workflow that the loop crashed on and removed the original workflow.
test workflow then succeeded.

none of that gets closer to truly understanding the issue, but a good workaround is just fine with me in this case!

1 Like

ugh. that seems to have only worked for the test workflow execution.
when the workflow ran on it’s cron trigger, it ran into the same error.