fix(core): Use pinned data only for manual mode (#8164)

## Summary
Fixes the issue that pinned data gets also used for production executions.

---------

Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
Jan Oberhauser 2023-12-27 18:22:33 +01:00 committed by GitHub
parent 2c6ffb0153
commit ea7e76fa3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View file

@ -25,6 +25,7 @@ import type {
IHttpRequestMethods,
IN8nHttpFullResponse,
INode,
IPinData,
IRunExecutionData,
IWebhookData,
IWebhookResponseData,
@ -514,8 +515,11 @@ export async function executeWebhook(
Object.assign(runExecutionData, runExecutionDataMerge);
}
if (workflowData.pinData) {
runExecutionData.resultData.pinData = workflowData.pinData;
let pinData: IPinData | undefined;
const usePinData = executionMode === 'manual';
if (usePinData) {
pinData = workflowData.pinData;
runExecutionData.resultData.pinData = pinData;
}
const runData: IWorkflowExecutionDataProcess = {
@ -523,7 +527,7 @@ export async function executeWebhook(
executionData: runExecutionData,
sessionId,
workflowData,
pinData: workflowData.pinData,
pinData,
userId: user.id,
};
@ -620,8 +624,8 @@ export async function executeWebhook(
return undefined;
}
if (workflowData.pinData) {
data.data.resultData.pinData = workflowData.pinData;
if (usePinData) {
data.data.resultData.pinData = pinData;
}
const returnData = WorkflowHelpers.getDataLastExecutedNodeData(data);

View file

@ -12,6 +12,7 @@ import type {
ExecutionError,
IDeferredPromise,
IExecuteResponsePromiseData,
IPinData,
IRun,
WorkflowExecuteMode,
WorkflowHooks,
@ -284,6 +285,11 @@ export class WorkflowRunner {
workflowTimeout = Math.min(workflowTimeout, config.getEnv('executions.maxTimeout'));
}
let pinData: IPinData | undefined;
if (data.executionMode === 'manual') {
pinData = data.pinData ?? data.workflowData.pinData;
}
const workflow = new Workflow({
id: workflowId,
name: data.workflowData.name,
@ -293,7 +299,7 @@ export class WorkflowRunner {
nodeTypes,
staticData: data.workflowData.staticData,
settings: workflowSettings,
pinData: data.pinData || data.workflowData.pinData,
pinData,
});
const additionalData = await WorkflowExecuteAdditionalData.getBase(
data.userId,