mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-24 23:22:38 +08:00
fix(editor): Preserve paired item data in pinned data (#21417)
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1046,11 +1046,19 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
delete nodeMetadata.value[nodeName].pinnedDataLastRemovedAt;
|
||||
}
|
||||
|
||||
const storedPinData = payload.data.map((item) =>
|
||||
isJsonKeyObject(item)
|
||||
? { json: item.json, ...(item.binary && { binary: item.binary }) }
|
||||
: { json: item },
|
||||
);
|
||||
const storedPinData = payload.data.map((item) => {
|
||||
// Store only essential properties: json, binary, and pairedItem
|
||||
// Exclude runtime properties (error, metadata, evaluationData, etc.)
|
||||
if (isJsonKeyObject(item)) {
|
||||
const { json, binary, pairedItem } = item;
|
||||
return {
|
||||
json,
|
||||
...(binary && { binary }),
|
||||
...(pairedItem !== undefined && { pairedItem }),
|
||||
};
|
||||
}
|
||||
return { json: item };
|
||||
});
|
||||
|
||||
workflow.value.pinData[nodeName] = storedPinData;
|
||||
workflowObject.value.setPinData(workflow.value.pinData);
|
||||
|
||||
@@ -794,19 +794,6 @@ export class WorkflowDataProxy {
|
||||
});
|
||||
};
|
||||
|
||||
const createInvalidPairedItemError = ({ nodeName }: { nodeName: string }) => {
|
||||
return createExpressionError("Can't get data for expression", {
|
||||
messageTemplate: 'Expression info invalid',
|
||||
functionality: 'pairedItem',
|
||||
functionOverrides: {
|
||||
message: "Can't get data",
|
||||
},
|
||||
nodeCause: nodeName,
|
||||
descriptionKey: 'pairedItemInvalidInfo',
|
||||
type: 'paired_item_invalid_info',
|
||||
});
|
||||
};
|
||||
|
||||
const createMissingPairedItemError = (
|
||||
nodeCause: string,
|
||||
usedMethodName: PairedItemMethod = PAIRED_ITEM_METHOD.PAIRED_ITEM,
|
||||
@@ -962,7 +949,7 @@ export class WorkflowDataProxy {
|
||||
// Done: reached the destination node in the ancestry chain
|
||||
if (sourceData.previousNode === destinationNodeName) {
|
||||
if (pairedItem.item >= outputData.length) {
|
||||
throw createInvalidPairedItemError({ nodeName: sourceData.previousNode });
|
||||
throw createMissingPairedItemError(sourceData.previousNode, usedMethodName);
|
||||
}
|
||||
|
||||
return item;
|
||||
|
||||
@@ -350,8 +350,9 @@ describe('WorkflowDataProxy', () => {
|
||||
} catch (error) {
|
||||
expect(error).toBeInstanceOf(ExpressionError);
|
||||
const exprError = error as ExpressionError;
|
||||
expect(exprError.message).toEqual("Can't get data for expression");
|
||||
expect(exprError.context.type).toEqual('paired_item_invalid_info');
|
||||
expect(exprError.message).toContain('Paired item data for item from node');
|
||||
expect(exprError.message).toContain('Edit Fields');
|
||||
expect(exprError.context.type).toEqual('paired_item_no_info');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user