Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Restore workflow ID during execution creation #8031

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/cli/src/commands/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import type {
INodeTypes,
IRun,
} from 'n8n-workflow';
import { Workflow, NodeOperationError, sleep, ApplicationError } from 'n8n-workflow';
import {
Workflow,
NodeOperationError,
sleep,
ApplicationError,
ErrorReporterProxy as EventReporter,
} from 'n8n-workflow';

import * as Db from '@/Db';
import * as ResponseHelper from '@/ResponseHelper';
Expand Down Expand Up @@ -130,7 +136,15 @@ export class Worker extends BaseCommand {
{ extra: { executionId } },
);
}
const workflowId = fullExecutionData.workflowData.id!;
const workflowId = fullExecutionData.workflowData.id!; // @tech_debt Ensure this is not optional

if (!workflowId) {
EventReporter.report('Detected ID-less workflow', {
level: 'info',
extra: { execution: fullExecutionData },
});
}

this.logger.info(
`Start job: ${job.id} (Workflow ID: ${workflowId} | Execution: ${executionId})`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
const { connections, nodes, name } = workflowData ?? {};
await this.executionDataRepository.insert({
executionId,
workflowData: { connections, nodes, name },
workflowData: { connections, nodes, name, id: workflowData?.id },
data: stringify(data),
});
return String(executionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ describe('ExecutionRepository', () => {
const executionDataRepo = Container.get(ExecutionDataRepository);
const executionData = await executionDataRepo.findOneBy({ executionId });
expect(executionData?.workflowData).toEqual({
id: workflow.id,
connections: workflow.connections,
nodes: workflow.nodes,
name: workflow.name,
Expand Down
10 changes: 9 additions & 1 deletion packages/workflow/src/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { RoutingNode } from './RoutingNode';
import { Expression } from './Expression';
import { NODES_WITH_RENAMABLE_CONTENT } from './Constants';
import { ApplicationError } from './errors/application.error';
import * as EventReporter from './ErrorReporterProxy';

function dedupe<T>(arr: T[]): T[] {
return [...new Set(arr)];
Expand Down Expand Up @@ -94,7 +95,14 @@ export class Workflow {
settings?: IWorkflowSettings;
pinData?: IPinData;
}) {
this.id = parameters.id as string;
if (!parameters.id) {
EventReporter.report('Detected ID-less workflow', {
level: 'info',
extra: { parameters },
});
}

this.id = parameters.id as string; // @tech_debt Ensure this is not optional
this.name = parameters.name;
this.nodeTypes = parameters.nodeTypes;
this.pinData = parameters.pinData;
Expand Down
Loading