Convert To File fails with "ERROR: The value in "data" is not set" even though the field "data" is set

Describe the problem/error/question

I’m working with the Stripe webhook API to send out emails to people who purchase my app. As Stripe sends multiple webhook calls at once, I had to create a debouncer in n8n that gets the event’s ID, saves it to a file, and any subsequent webhook calls compare their IDs against the saved ID; if the ID matches, it means it’s the same event and the webhook gets ignored (to not send multiple emails). If it doesn’t match it means it’s a new event and the process repeats.

To accomplish this, I’m using a workflow centered around the “Read Files from Disk” and “Write Fields to Disk” nodes.

As you have to convert from/to binary to save the files, I have to use the “Convert to Text File” node to get the data ready for writing.

Unfortunately, even though I have a JSON coming in that only has the “data” field, and I have set the “Text Input Field” field to “data”, I still get the error “The value in “data” is not set”. I have tried using the “Rename Keys” action to force the new event ID to have the correct key (data), but that still doesn’t work.

What is the error message (if any)?

ERROR: The value in “data” is not set

Please share your workflow

Share the output returned by the last node

NodeOperationError: The value in "data" is not set
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Files/ConvertToFile/actions/toText.operation.js:110:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/Files/ConvertToFile/ConvertToFile.node.js:138:26)
    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

Information on your n8n setup

  • n8n version: 1.29.1
  • Database (default: SQLite): SQLite
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Fedora Server 37

@buresdv , to be honest, your workflow doesn’t make much sense to me, at least it cannot perform what you are after. The problem is with the usage of IF node. If you need to compare the values in your file and those coming from Stripe you would need to use Merge node or other techniques but not IF the way you did.

As I do not know how the “multiple webhook calls” data looks like I’m going simply to demonstrate how to check if the value is in the data set to have it saved to disk if not.

Thank you for the tip. Concerning the original problem, look at this:
Snímek obrazovky 2024-02-27 v 14.07.39

As you can see, the Stripe trigger gets activated twice at the same time. When a user makes a transaction in Stripe, Stripe sends two+ calls to the webhook at the same time (sometimes a few milliseconds apart).

Stripe recommends that you use some kind of persistent storage to check if the ID of two events are the same, and discard the extra triggers in case the IDs match. This is what I’m trying to do, but I don’t want to create an entire database just for this one thing, so I’m using a file instead. And this is where I ran into the problem I described in the OP.

If I don’t do any debouncing, the workflow triggered by the webhook call from Stripe would send up to four emails to the user at the same time, which would be pretty annoying for them.

@buresdv , are the payloads for the two calls identical too? Perhaps they correspond to different events taking place in Stripe you subscribed for? Multiple webhooks calls could be normal but if they are totally identical (the very same payload) then it doesn’t sound right. You might need to check with Stripe support.

It is quite common for the webhook to resend the payload if it did not receive the expected response from the endpoint (say, after 30 secs). However, in your case, it does not look like a repeated call as they come simultaneously.

You were right about there being something wrong with Stripe. The duplicated calls were a result of a problem on their side that they had to resolve via a support ticket, so that part of the problem is resolved now :slight_smile:

Still, I think we should get to the bottom of the issue of the OP (the n8n error), as other people might stumble upon this thread with the same problem in a different context.

@buresdv , you haven’t shared any specifics about the error you are getting. If you still use the same workflow you started this thread with then I expect it to fail. If you updated the workflow, then please, share its structure and provide the details at what node it happens and what the error is.