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

View file

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