{"record":{"id":"7e7030ddd07da64c","repo":"n8n-io/n8n","slug":"workflow-requires-id-string-name-string-wo-7e7030","errorCode":null,"errorMessage":"workflow() requires (id: string, name: string). workflow() requires a string name as second argument, but received ${receivedName}. Example: workflow('my-workflow-id', 'My Workflow Name')","messagePattern":"workflow\\(\\) requires \\(id: string, name: string\\)\\. workflow\\(\\) requires a string name as second argument, but received (.+?)\\. Example: workflow\\('my-workflow-id', 'My Workflow Name'\\)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/workflow-sdk/src/workflow-builder.ts","lineNumber":1317,"sourceCode":" * Create a new workflow builder\n */\nfunction createWorkflow(\n\tid: string,\n\tname: string,\n\toptions?: WorkflowSettings | WorkflowBuilderOptions,\n): WorkflowBuilder {\n\tif (typeof id !== 'string') {\n\t\tconst receivedId = Array.isArray(id) ? 'an array' : typeof id;\n\t\tthrow new TypeError(\n\t\t\t// eslint-disable-next-line n8n-local-rules/no-interpolation-in-regular-string\n\t\t\t'workflow() requires (id: string, name: string). ' +\n\t\t\t\t`workflow() requires a string id as first argument, but received ${receivedId}. ` +\n\t\t\t\t\"Example: workflow('my-workflow-id', 'My Workflow Name')\",\n\t\t);\n\t}\n\tif (typeof name !== 'string') {\n\t\tconst receivedName = Array.isArray(name) ? 'an array' : typeof name;\n\t\tthrow new TypeError(\n\t\t\t// eslint-disable-next-line n8n-local-rules/no-interpolation-in-regular-string\n\t\t\t'workflow() requires (id: string, name: string). ' +\n\t\t\t\t`workflow() requires a string name as second argument, but received ${receivedName}. ` +\n\t\t\t\t\"Example: workflow('my-workflow-id', 'My Workflow Name')\",\n\t\t);\n\t}\n\tif (\n\t\toptions !== undefined &&\n\t\t(Array.isArray(options) ||\n\t\t\t(typeof options === 'object' &&\n\t\t\t\toptions !== null &&\n\t\t\t\t('nodes' in options || 'connections' in options)))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'workflow() third argument is settings, not workflow structure. ' +\n\t\t\t\t'Do not pass nodes or connections here — use .add() and .to() to build the workflow. ' +\n\t\t\t\t\"Example: workflow('id', 'Name').add(trigger({...})).to(node({...}))\",\n\t\t);","sourceCodeStart":1299,"sourceCodeEnd":1335,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder.ts#L1299-L1335","documentation":"The workflow() factory requires its second argument to be a string name. Same guard shape as the id check: typeof name === 'string', with the received type reported. The name is stored as the workflow's human-readable name and used in serialization, so non-strings are rejected immediately.","triggerScenarios":"Passing an object, number, array, null, or undefined as the name argument. Often happens when a caller swaps argument order or passes a config object where the name should go.","commonSituations":"Argument-order confusion (passing options before name); undefined from an optional field; numeric or object names from external data.","solutions":["Ensure the second argument is a string: workflow('id', String(name) || 'Untitled').","Re-order arguments if they were swapped.","Type the caller so a non-string name is a compile error."],"exampleFix":"// before\nworkflow('id', { title: 'My Workflow' }); // throws\n\n// after\nworkflow('id', 'My Workflow');","handlingStrategy":"type-guard","validationCode":"function isStringName(v: unknown): v is string {\n  return typeof v === 'string';\n}\nif (!isStringName(name)) name = String(name);","typeGuard":"function isStringName(v: unknown): v is string {\n  return typeof v === 'string';\n}","tryCatchPattern":null,"preventionTips":["Pass a literal string name as the second argument to workflow().","Do not swap argument order (options before name).","Type the name variable as string; default missing names to 'Untitled'."],"tags":["workflow-builder","validation","typeerror","factory"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}