fix(core): Improve error message when resolving itemMatching with pinned data (no-changelog) (#12641)

This commit is contained in:
Tomi Turtiainen
2025-01-17 16:23:45 +02:00
committed by GitHub
parent 05858c2153
commit 395f2ad0dc
5 changed files with 406 additions and 14 deletions

View File

@@ -703,17 +703,19 @@ export class WorkflowDataProxy {
});
};
const createMissingPairedItemError = (nodeCause: string) => {
return createExpressionError("Can't get data for expression", {
messageTemplate: 'Info for expression missing from previous node',
const createMissingPairedItemError = (
nodeCause: string,
usedMethodName: 'itemMatching' | 'pairedItem' | 'item' | '$getPairedItem' = 'pairedItem',
) => {
const message = `Using the ${usedMethodName} method doesn't work with pinned data in this scenario. Please unpin '${nodeCause}' and try again.`;
return new ExpressionError(message, {
runIndex: that.runIndex,
itemIndex: that.itemIndex,
functionality: 'pairedItem',
functionOverrides: {
message: "Can't get data",
},
nodeCause,
descriptionKey: isScriptingNode(nodeCause, that.workflow)
? 'pairedItemNoInfoCodeNode'
: 'pairedItemNoInfo',
nodeCause,
causeDetailed: `Missing pairedItem data (node '${nodeCause}' probably didn't supply it)`,
type: 'paired_item_no_info',
});
@@ -737,6 +739,7 @@ export class WorkflowDataProxy {
destinationNodeName: string,
incomingSourceData: ISourceData | null,
pairedItem: IPairedItemData,
usedMethodName: 'pairedItem' | 'itemMatching' | 'item' | '$getPairedItem' = '$getPairedItem',
): INodeExecutionData | null => {
let taskData: ITaskData | undefined;
@@ -790,7 +793,7 @@ export class WorkflowDataProxy {
const itemPreviousNode: INodeExecutionData = previousNodeOutputData[pairedItem.item];
if (itemPreviousNode.pairedItem === undefined) {
throw createMissingPairedItemError(sourceData.previousNode);
throw createMissingPairedItemError(sourceData.previousNode, usedMethodName);
}
if (Array.isArray(itemPreviousNode.pairedItem)) {
@@ -806,7 +809,7 @@ export class WorkflowDataProxy {
throw new ApplicationError('Not found');
}
return getPairedItem(destinationNodeName, source[itemInput], item);
return getPairedItem(destinationNodeName, source[itemInput], item, usedMethodName);
} catch (error) {
// Means pairedItem could not be found
return null;
@@ -858,6 +861,7 @@ export class WorkflowDataProxy {
// A trigger node got reached, so looks like that that item can not be resolved
throw createNoConnectionError(destinationNodeName);
}
throw createExpressionError('Cant get data for expression', {
messageTemplate: 'Cant get data for expression under %%PARAMETER%% field',
functionality: 'pairedItem',
@@ -1039,7 +1043,7 @@ export class WorkflowDataProxy {
);
}
if (['pairedItem', 'itemMatching', 'item'].includes(property as string)) {
if (property === 'pairedItem' || property === 'itemMatching' || property === 'item') {
// Before resolving the pairedItem make sure that the requested node comes in the
// graph before the current one
const activeNode = that.workflow.getNode(that.activeNodeName);
@@ -1101,7 +1105,7 @@ export class WorkflowDataProxy {
const pairedItem = input.pairedItem as IPairedItemData;
if (pairedItem === undefined) {
throw createMissingPairedItemError(that.activeNodeName);
throw createMissingPairedItemError(that.activeNodeName, property);
}
if (!that.executeData?.source) {
@@ -1122,7 +1126,7 @@ export class WorkflowDataProxy {
that.executeData.source.main[pairedItem.input || 0] ??
that.executeData.source.main[0];
return getPairedItem(nodeName, sourceData, pairedItem);
return getPairedItem(nodeName, sourceData, pairedItem, property);
};
if (property === 'item') {