{"record":{"id":"012e1b59b9439f6b","repo":"n8n-io/n8n","slug":"workflow-requires-id-string-name-string-wo","errorCode":null,"errorMessage":"workflow() requires (id: string, name: string). workflow() requires a string id as first argument, but received ${receivedId}. Example: workflow('my-workflow-id', 'My Workflow Name')","messagePattern":"workflow\\(\\) requires \\(id: string, name: string\\)\\. workflow\\(\\) requires a string id as first 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":1308,"sourceCode":"\toptions: WorkflowSettings | WorkflowBuilderOptions | undefined,\n): options is WorkflowBuilderOptions {\n\tif (!options) return false;\n\t// WorkflowBuilderOptions has 'settings' or 'registry' as keys\n\t// WorkflowSettings has keys like 'timezone', 'executionOrder', etc.\n\treturn 'settings' in options || 'registry' in options;\n}\n\n/**\n * 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) ||","sourceCodeStart":1290,"sourceCodeEnd":1326,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/workflow-sdk/src/workflow-builder.ts#L1290-L1326","documentation":"The workflow() factory requires its first argument to be a string id. A runtime TypeError guard checks typeof id === 'string' and reports the actual received type (distinguishing arrays from objects). The id is used verbatim as the workflow's stable identifier, so non-string values are rejected up front rather than causing subtle serialization issues later.","triggerScenarios":"Passing a number (e.g. a DB id), an object, an array, undefined, or null as the first argument to workflow(). Common when a caller reads an id from JSON/DB as a number and forwards it unchanged.","commonSituations":"Numeric IDs from a database; destructuring that yields undefined; loosely-typed glue code; migrated callers that previously passed any value.","solutions":["Coerce the id to a string at the call site: workflow(String(myId), name).","Fix the source so the id is already a string (e.g. store as text, or JSON.parse with a string id).","Add a type annotation on the caller's id variable so TypeScript rejects non-strings at compile time."],"exampleFix":"// before\nworkflow(42, 'My Workflow'); // throws\n\n// after\nworkflow(String(42), 'My Workflow');","handlingStrategy":"type-guard","validationCode":"function isStringId(v: unknown): v is string {\n  return typeof v === 'string';\n}\nif (!isStringId(id)) id = String(id);","typeGuard":"function isStringId(v: unknown): v is string {\n  return typeof v === 'string';\n}","tryCatchPattern":null,"preventionTips":["Coerce numeric/DB ids to string before calling workflow(): workflow(String(id), name).","Type the id variable as string at the source.","Validate external input (JSON, query params) before forwarding to workflow()."],"tags":["workflow-builder","validation","typeerror","factory"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}