fix(core): Fix missing execution ID in webhook-based workflow producing binary data (#7244)

Story: https://linear.app/n8n/issue/PAY-839

This is a longstanding bug, fixed now so that the S3 backend for binary
data can use execution IDs as part of the filename.

To reproduce:

1. Set up a workflow with a POST Webhook node that accepts binary data.
2. Activate the workflow and call it sending a binary file, e.g. `curl
-X POST -F "file=@/path/to/binary/file/test.jpg"
http://localhost:5678/webhook/uuid`
3. Check `~/.n8n/binaryData`. The binary data and metadata files will be
missing the execution ID, e.g. `11869055-83c4-4493-876a-9092c4708b9b`
instead of `39011869055-83c4-4493-876a-9092c4708b9b`.
This commit is contained in:
Iván Ovejero
2023-09-25 12:30:28 +02:00
committed by GitHub
parent dcc9cc13ed
commit 33991e92d0
6 changed files with 156 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ import fs from 'fs/promises';
import path from 'path';
import { v4 as uuid } from 'uuid';
import { jsonParse } from 'n8n-workflow';
import { rename } from 'node:fs/promises';
import { FileNotFoundError } from '../errors';
import { ensureDirExists } from './utils';
@@ -124,6 +125,16 @@ export class FileSystemManager implements BinaryData.Manager {
return newFileId;
}
async rename(oldFileId: string, newFileId: string) {
const oldPath = this.getPath(oldFileId);
const newPath = this.getPath(newFileId);
await Promise.all([
rename(oldPath, newPath),
rename(`${oldPath}.metadata`, `${newPath}.metadata`),
]);
}
// ----------------------------------
// private methods
// ----------------------------------