{"record":{"id":"539233767918349f","repo":"n8n-io/n8n","slug":"sub-agent-task-name-must-contain-at-least-one-alph","errorCode":null,"errorMessage":"Sub-agent task name must contain at least one alphanumeric character","messagePattern":"Sub-agent task name must contain at least one alphanumeric character","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/agents/src/runtime/tools/sub-agent-task-path.ts","lineNumber":73,"sourceCode":" * lowercase, collapse each run of non-alphanumerics into a single underscore,\n * strip leading/trailing underscores, and cap the length — producing segments\n * that are collision-resistant, log/URL-safe, and accepted by\n * {@link SUB_AGENT_TASK_PATH_PATTERN}.\n *\n * @throws if nothing alphanumeric survives (we refuse to build a nameless path).\n */\nexport function sanitizeSubAgentTaskName(taskName: string): string {\n\tconst sanitized = taskName\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '_')\n\t\t.replace(/_+/g, '_')\n\t\t.replace(/^_+|_+$/g, '')\n\t\t.slice(0, MAX_TASK_NAME_LENGTH)\n\t\t.replace(/_+$/g, '');\n\n\tif (!sanitized) {\n\t\tthrow new Error('Sub-agent task name must contain at least one alphanumeric character');\n\t}\n\n\treturn sanitized;\n}\n\n/** Type guard: does this string match `/root` or `/root/<segment>`? */\nexport function isSubAgentTaskPath(value: string): value is SubAgentTaskPath {\n\treturn SUB_AGENT_TASK_PATH_PATTERN.test(value);\n}\n\n/**\n * Assert (and type-narrow) that a string is a valid task path. Used to validate\n * paths that were constructed here or received from elsewhere before we rely on\n * their shape.\n */\nexport function assertSubAgentTaskPath(value: string): asserts value is SubAgentTaskPath {\n\tif (!isSubAgentTaskPath(value)) {\n\t\tthrow new Error(`Invalid sub-agent task path: ${value}`);","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/agents/src/runtime/tools/sub-agent-task-path.ts#L55-L91","documentation":"Thrown by sanitizeSubAgentTaskName when the input string, after sanitization (trim, lowercase, replace non-alphanumeric runs with underscores, strip leading/trailing underscores, truncate to MAX_TASK_NAME_LENGTH), becomes empty. The task name forms part of the task path used for tracking and persistence, so at least one alphanumeric character is required.","triggerScenarios":"Passing a taskName to a delegation that consists entirely of whitespace, punctuation, emojis, or other non-alphanumeric characters. For example '!!!', '   ', '---', '🎵🎵', or a string that after sanitization only had leading/trailing underscores that got stripped.","commonSituations":"User-provided or LLM-generated task names that are decorative (emojis, symbols only). Empty or whitespace-only task names from upstream input. Task names derived from localized text that contains no ASCII alphanumeric characters.","solutions":["Validate that the task name contains at least one ASCII alphanumeric character before passing it to delegation.","Provide a fallback default task name if sanitization would produce an empty string.","Pre-filter the task name to strip non-alphanumeric characters and check for emptiness."],"exampleFix":"// before\ndelegate({ taskName: '---!!!---', subAgentId: 'a' });\n// after\nconst rawName = '---!!!---';\nconst safeName = /[a-z0-9]/i.test(rawName) ? rawName : 'task';\ndelegate({ taskName: safeName, subAgentId: 'a' });","handlingStrategy":"validation","validationCode":"function hasAlphanumeric(s: string): boolean {\n  return /[a-z0-9]/i.test(s);\n}\nconst taskName = hasAlphanumeric(rawName) ? rawName : 'untitled_task';","typeGuard":"function isSanitizableTaskName(name: unknown): name is string {\n  return typeof name === 'string' && /[a-z0-9]/i.test(name);\n}","tryCatchPattern":null,"preventionTips":["Validate that task names contain at least one ASCII letter or digit before delegation.","Provide a fallback name like 'task' when the input is purely symbolic.","Pre-filter user-generated task names to strip non-alphanumeric characters."],"tags":["task-path","sanitization","validation","naming"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}