{"record":{"id":"4ff0c9c497e4dc1c","repo":"n8n-io/n8n","slug":"delete-prebuilt-workflows-applies-to-prebuilt","errorCode":null,"errorMessage":"--delete-prebuilt-workflows applies to --prebuilt-workflows. --build-via-mcp already cleans up the workflows it builds unless --keep-workflows is set.","messagePattern":"--delete-prebuilt-workflows applies to --prebuilt-workflows\\. --build-via-mcp already cleans up the workflows it builds unless --keep-workflows is set\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/cli/args.ts","lineNumber":184,"sourceCode":"\tbuildTimeoutMs: z.number().int().nonnegative().default(DEFAULT_MCP_BUILD_TIMEOUT_MS),\n});\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\nexport function parseCliArgs(argv: string[]): CliArgs {\n\tconst raw = parseRawArgs(argv);\n\tconst validated = cliArgsSchema.parse(raw);\n\t// --build-via-mcp checks first: they give clearer guidance than the generic\n\t// --delete-prebuilt-workflows check below when both are combined.\n\tif (validated.buildViaMcp && validated.prebuiltWorkflows) {\n\t\tthrow new Error(\n\t\t\t'--build-via-mcp is incompatible with --prebuilt-workflows. --build-via-mcp builds fresh workflows via the MCP server on each lane; --prebuilt-workflows verifies existing ones.',\n\t\t);\n\t}\n\tif (validated.buildViaMcp && validated.deletePrebuiltWorkflows) {\n\t\tthrow new Error(\n\t\t\t'--delete-prebuilt-workflows applies to --prebuilt-workflows. --build-via-mcp already cleans up the workflows it builds unless --keep-workflows is set.',\n\t\t);\n\t}\n\t// MCP builds are LangSmith-only: the keyless direct loop parallelizes\n\t// iterations without the lane allocator, so its 4-per-lane build cap applies\n\t// PER ITERATION — concurrent `claude` sessions would scale with\n\t// lanes × iterations × 4 and flood the shared Anthropic budget. Fail fast\n\t// instead of teaching the direct loop (tech debt slated for removal) MCP builds.\n\tif (validated.buildViaMcp && !process.env.LANGSMITH_API_KEY) {\n\t\tthrow new Error(\n\t\t\t'--build-via-mcp requires LangSmith experiment tracking — set LANGSMITH_API_KEY. The no-LangSmith direct loop does not support MCP builds.',\n\t\t);\n\t}\n\t// Build knobs without --build-via-mcp would parse fine and then be silently\n\t// ignored — the run would look like it honored them. Fail loudly instead.\n\tif (!validated.buildViaMcp && raw.buildOnlyFlags.length > 0) {\n\t\tthrow new Error(\n\t\t\t`${[...new Set(raw.buildOnlyFlags)].join(', ')} only take${raw.buildOnlyFlags.length === 1 ? 's' : ''} effect with --build-via-mcp — pass it, or drop the flag(s).`,","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/cli/args.ts#L166-L202","documentation":"This error is thrown by parseCliArgs() in the instance-ai workflow evaluator CLI when both --build-via-mcp and --delete-prebuilt-workflows are passed together. --delete-prebuilt-workflows only applies to workflows loaded via --prebuilt-workflows, whereas --build-via-mcp builds fresh workflows via the MCP server on each lane and has its own lifecycle (it cleans up after itself unless --keep-workflows is set). Combining the two is a no-op at best and a confusing contradiction at worst, so the parser rejects it eagerly.","triggerScenarios":"Invoking the eval CLI with both flags: `... --build-via-mcp --delete-prebuilt-workflows`. The check fires after Zod validation succeeds but before any run logic, at args.ts:183. It is checked before the LANGSMITH_API_KEY check so the user gets the clearest guidance first.","commonSituations":"A developer copy-pastes a long flag list from a previous --prebuilt-workflows run and appends --build-via-mcp without removing --delete-prebuilt-workflows, or vice versa. Also occurs when refactoring a run script from one mode to the other and forgetting to strip the now-irrelevant flag.","solutions":["Remove --delete-prebuilt-workflows from the command: MCP builds auto-clean unless --keep-workflows is set, so the flag is redundant.","If you want MCP builds retained, drop --delete-prebuilt-workflows and add --keep-workflows instead.","If you actually want to delete pre-built workflows, drop --build-via-mcp and use --prebuilt-workflows <path> --delete-prebuilt-workflows."],"exampleFix":"// before\npnpm eval:instance-ai --build-via-mcp --delete-prebuilt-workflows --base-url http://localhost:5678\n// after\npnpm eval:instance-ai --build-via-mcp --base-url http://localhost:5678","handlingStrategy":"validation","validationCode":"// Before invoking parseCliArgs, or in a wrapper script:\nfunction assertNoBuildViaMcpWithDelete(args: string[]): void {\n  if (args.includes('--build-via-mcp') && args.includes('--delete-prebuilt-workflows')) {\n    throw new Error('Cannot combine --build-via-mcp with --delete-prebuilt-workflows (MCP auto-cleans).');\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep MCP-mode and prebuilt-mode flag templates in separate scripts to avoid cross-contamination.","Audit command templates after switching build modes: grep for --delete-prebuilt-workflows whenever --build-via-mcp is present.","Document the two exclusive run modes in your eval runbook."],"tags":["cli","argument-validation","instance-ai","evaluations"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}