diff --git a/packages/cli/commands/execute.ts b/packages/cli/commands/execute.ts index 3861030f80..51a24bea2c 100644 --- a/packages/cli/commands/execute.ts +++ b/packages/cli/commands/execute.ts @@ -2,7 +2,12 @@ /* eslint-disable no-console */ import { promises as fs } from 'fs'; import { Command, flags } from '@oclif/command'; -import { BinaryDataManager, IBinaryDataConfig, UserSettings } from 'n8n-core'; +import { + BinaryDataManager, + IBinaryDataConfig, + UserSettings, + PLACEHOLDER_EMPTY_WORKFLOW_ID, +} from 'n8n-core'; import { INode, LoggerProxy } from 'n8n-workflow'; import { @@ -96,8 +101,8 @@ export class Execute extends Command { console.info(`The file "${flags.file}" does not contain valid workflow data.`); return; } - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - workflowId = workflowData.id!.toString(); + + workflowId = workflowData.id ? workflowData.id.toString() : PLACEHOLDER_EMPTY_WORKFLOW_ID; } // Wait till the database is ready diff --git a/packages/core/src/Constants.ts b/packages/core/src/Constants.ts index 4e72f53f9c..43103df5ac 100644 --- a/packages/core/src/Constants.ts +++ b/packages/core/src/Constants.ts @@ -6,5 +6,6 @@ export const USER_FOLDER_ENV_OVERWRITE = 'N8N_USER_FOLDER'; export const USER_SETTINGS_FILE_NAME = 'config'; export const USER_SETTINGS_SUBFOLDER = '.n8n'; export const PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKOWN__'; +export const PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__'; export const TUNNEL_SUBDOMAIN_ENV = 'N8N_TUNNEL_SUBDOMAIN'; export const WAIT_TIME_UNLIMITED = '3000-01-01T00:00:00.000Z';