mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-12 15:44:06 -08:00
fix(core): Account for itemless case on restoring binary data ID (#7305)
https://linear.app/n8n/issue/PAY-862
This commit is contained in:
parent
d1b6c7fd79
commit
1691223789
|
@ -25,7 +25,7 @@ export async function restoreBinaryDataId(run: IRun, executionId: string) {
|
||||||
const { runData } = run.data.resultData;
|
const { runData } = run.data.resultData;
|
||||||
|
|
||||||
const promises = Object.keys(runData).map(async (nodeName) => {
|
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 || !isMissingExecutionId(binaryDataId)) return;
|
if (!binaryDataId || !isMissingExecutionId(binaryDataId)) return;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { BinaryDataService } from 'n8n-core';
|
||||||
import { mockInstance } from '../integration/shared/utils/mocking';
|
import { mockInstance } from '../integration/shared/utils/mocking';
|
||||||
import type { IRun } from 'n8n-workflow';
|
import type { IRun } from 'n8n-workflow';
|
||||||
|
|
||||||
function toIRun(item: object) {
|
function toIRun(item?: object) {
|
||||||
return {
|
return {
|
||||||
data: {
|
data: {
|
||||||
resultData: {
|
resultData: {
|
||||||
|
@ -84,4 +84,14 @@ describe('restoreBinaryDataId()', () => {
|
||||||
expect(binaryDataService.rename).not.toHaveBeenCalled();
|
expect(binaryDataService.rename).not.toHaveBeenCalled();
|
||||||
expect(getDataId(run, 'json')).toBe(dataId);
|
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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue