Hello,
I wanted to ask about a problem I faced during the development of a workflow. It seems to me that it is a bug, but as I am not completely sure that it is the expected behaviour I ask about it in this category.
Problem detected
I have a workflow that has a Webhook and after some processing the workflow ends generating a TSV file and returning it as binary data with content-type text/tab-separated-values
Below is the first approach I followed that didn’t work:
I expected that setting the content-type in the Respond to Webhook node should make the workflow return the content-type header with the text/tab-separated-values value. But these were the response headers:
Solution
I checked the source code of the Respond to Webhook node to know what was going on. And saw these lines in the case of binary response: n8n/RespondToWebhook.node.ts at master · n8n-io/n8n · GitHub
So I updated the workflow and set the mimeType in the Move Binary Data:
Now the response has the expected content-type:
Even when I set the content-type header in the Respond to Webhook node with the value any value. In fact, I have to set the header in that node even if I know it will be overwritten, because if I don’t set it the response will be without the content-type header.
So, here is my question:
Question
Is that the expected behaviour in case of a binary response in the Respond to Webhook node?
Or is a bug and those lines should be as the following?
if (!headers['content-type']) {
headers['content-type'] = binaryData.mimeType;
}
For me makes more sense that if you set the content-type in the Respond to Webhook header is because you want that value. And only in case if you don’t set it, use the mimeType for the conent-type.
In case the current behaviour is the expected one, I would update the Respond to Webhook documentation page to add a warning to explain the behaviour of the content-type header in case the response type is binary.
Thanks in advance.
n8n setup
- n8n version: 0.209.4
- Database you’re using (default: SQLite): SQLite
- Running n8n with the execution process [own(default), main]: own
- Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker