fix(core): Fix expressions in webhook nodes(Form, Webhook) to access previous node's data (#10247)

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Michael Kret 2024-08-01 11:21:58 +03:00 committed by GitHub
parent 1608d2527b
commit 88a170176a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 6 deletions

View file

@ -256,6 +256,10 @@ export async function executeWebhook(
// Prepare everything that is needed to run the workflow
const additionalData = await WorkflowExecuteAdditionalData.getBase();
if (executionId) {
additionalData.executionId = executionId;
}
// Get the responseMode
const responseMode = workflow.expression.getSimpleParameterValue(
workflowStartNode,
@ -359,6 +363,7 @@ export async function executeWebhook(
additionalData,
NodeExecuteFunctions,
executionMode,
runExecutionData ?? null,
);
Container.get(WorkflowStatisticsService).emit('nodeFetchedData', {
workflowId: workflow.id,

View file

@ -4212,8 +4212,9 @@ export function getExecuteWebhookFunctions(
mode: WorkflowExecuteMode,
webhookData: IWebhookData,
closeFunctions: CloseFunction[],
runExecutionData: IRunExecutionData | null,
): IWebhookFunctions {
return ((workflow: Workflow, node: INode) => {
return ((workflow: Workflow, node: INode, runExecutionData: IRunExecutionData | null) => {
return {
...getCommonWorkflowFunctions(workflow, node, additionalData),
getBodyData(): IDataObject {
@ -4274,10 +4275,21 @@ export function getExecuteWebhookFunctions(
fallbackValue?: any,
options?: IGetNodeParameterOptions,
): NodeParameterValueType | object => {
const runExecutionData: IRunExecutionData | null = null;
const itemIndex = 0;
const runIndex = 0;
const connectionInputData: INodeExecutionData[] = [];
let connectionInputData: INodeExecutionData[] = [];
let executionData: IExecuteData | undefined;
if (runExecutionData?.executionData !== undefined) {
executionData = runExecutionData.executionData.nodeExecutionStack[0];
if (executionData !== undefined) {
connectionInputData = executionData.data.main[0]!;
}
}
const additionalKeys = getAdditionalKeys(additionalData, mode, runExecutionData);
return getNodeParameter(
workflow,
@ -4288,8 +4300,8 @@ export function getExecuteWebhookFunctions(
parameterName,
itemIndex,
mode,
getAdditionalKeys(additionalData, mode, null),
undefined,
additionalKeys,
executionData,
fallbackValue,
options,
);
@ -4336,5 +4348,5 @@ export function getExecuteWebhookFunctions(
},
nodeHelpers: getNodeHelperFunctions(additionalData, workflow.id),
};
})(workflow, node);
})(workflow, node, runExecutionData);
}

View file

@ -466,6 +466,7 @@ export interface IGetExecuteWebhookFunctions {
mode: WorkflowExecuteMode,
webhookData: IWebhookData,
closeFunctions: CloseFunction[],
runExecutionData: IRunExecutionData | null,
): IWebhookFunctions;
}

View file

@ -1237,6 +1237,7 @@ export class Workflow {
additionalData: IWorkflowExecuteAdditionalData,
nodeExecuteFunctions: INodeExecuteFunctions,
mode: WorkflowExecuteMode,
runExecutionData: IRunExecutionData | null,
): Promise<IWebhookResponseData> {
const nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
if (nodeType === undefined) {
@ -1258,6 +1259,7 @@ export class Workflow {
mode,
webhookData,
closeFunctions,
runExecutionData,
);
return nodeType instanceof Node
? await nodeType.webhook(context)