mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix: Prevent undefined issues when restoring binary data (#7419)
Github issue / Community forum post (link here to close automatically): --------- Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
parent
367255ab2c
commit
46977a2aff
|
@ -20,7 +20,7 @@ export async function restoreBinaryDataId(run: IRun, executionId: string) {
|
|||
const { runData } = run.data.resultData;
|
||||
|
||||
const promises = Object.keys(runData).map(async (nodeName) => {
|
||||
const binaryDataId = runData[nodeName]?.[0]?.data?.main?.[0]?.[0]?.binary?.data.id;
|
||||
const binaryDataId = runData[nodeName]?.[0]?.data?.main?.[0]?.[0]?.binary?.data?.id;
|
||||
|
||||
if (!binaryDataId) return;
|
||||
|
||||
|
|
|
@ -101,6 +101,32 @@ for (const mode of ['filesystem-v2', 's3'] as const) {
|
|||
expect(binaryDataService.rename).not.toHaveBeenCalled();
|
||||
expect(getDataId(run, 'json')).toBe(dataId);
|
||||
});
|
||||
|
||||
it('should do nothing on itemless case', async () => {
|
||||
const executionId = '999';
|
||||
|
||||
const promise = restoreBinaryDataId(toIRun(), executionId);
|
||||
|
||||
await expect(promise).resolves.not.toThrow();
|
||||
|
||||
expect(binaryDataService.rename).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should do nothing if data is undefined', async () => {
|
||||
const executionId = '999';
|
||||
|
||||
const run = toIRun({
|
||||
json: {
|
||||
data: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const promise = restoreBinaryDataId(run, executionId);
|
||||
|
||||
await expect(promise).resolves.not.toThrow();
|
||||
|
||||
expect(binaryDataService.rename).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue