{"record":{"id":"753aadcbf87ced07","repo":"mastra-ai/mastra","slug":"schedules-invalid-id","errorCode":"SCHEDULES_INVALID_ID","errorMessage":"schedules.create: id \"${rawId}\" is empty after normalization. Provide an id with at least one alphanumeric character.","messagePattern":"schedules\\.create: id \"(.+?)\" is empty after normalization\\. Provide an id with at least one alphanumeric character\\.","errorType":"error_code","errorClass":"MastraError","httpStatus":400,"severity":"error","filePath":"packages/core/src/schedules/schedules.ts","lineNumber":41,"sourceCode":" * string when nothing slug-able remains.\n */\nfunction canonicalizeScheduleId(rawId: string, prefix: string): string {\n  const trimmed = rawId.trim();\n  const withoutPrefix = trimmed.startsWith(prefix) ? trimmed.slice(prefix.length) : trimmed;\n  const slug = slugify(withoutPrefix);\n  if (!slug) return '';\n  return `${prefix}${slug}`;\n}\n\n/**\n * Normalize a caller-supplied schedule id for `create`. Throws\n * `SCHEDULES_INVALID_ID` when the id is empty after normalization so callers\n * cannot create an unaddressable schedule.\n */\nfunction normalizeScheduleId(rawId: string, prefix: string): string {\n  const canonical = canonicalizeScheduleId(rawId, prefix);\n  if (!canonical) {\n    throw new MastraError({\n      id: 'SCHEDULES_INVALID_ID',\n      domain: ErrorDomain.AGENT,\n      category: ErrorCategory.USER,\n      details: { status: 400 },\n      text: `schedules.create: id \"${rawId}\" is empty after normalization. Provide an id with at least one alphanumeric character.`,\n    });\n  }\n  return canonical;\n}\n\n/**\n * Flat agent-schedule view returned by the {@link Schedules} service.\n * Projects the underlying `Schedule` row + `target.type === 'agent'` payload\n * onto a single object so callers never have to know about the schedules\n * storage shape. Discriminate from {@link WorkflowSchedule} via the\n * `agentId` field.\n */\nexport interface AgentSchedule {","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/schedules/schedules.ts#L23-L59","documentation":"`normalizeScheduleId` in packages/core/src/schedules/schedules.ts:41 slugifies the caller-supplied schedule id into a canonical `<prefix><slug>` form. If nothing slug-able remains (no alphanumeric characters survive trimming/slugification), the id cannot be addressed in storage or URLs, so `SCHEDULES_INVALID_ID` is thrown to prevent creating an unaddressable schedule. It is a 400-class user error from `schedules.create` (and other id-consuming paths).","triggerScenarios":"Calling `schedules.create({ id: ... })` where the id normalizes to empty: an empty string, whitespace only (`'   '`), a string of only punctuation/symbols (`'---'`, `'___'`, `'###'`), or a string consisting solely of the prefix (e.g. `id: 'agent_'` for an agent schedule).","commonSituations":"Building ids dynamically from data (template strings interpolating empty/undefined-ish values), stripping characters during sanitization until only separators remain, passing a variable that is empty at runtime, or passing only the `agent_`/`workflow_` prefix assuming it counts as an id.","solutions":["Pass an id containing at least one alphanumeric character (e.g. `nightly-summary`); the `agent_`/`workflow_` prefix is optional since it is added if missing.","Sanitize/validate the id with the same slugify rules before calling create and fall back to a generated id (e.g. randomUUID) when the slug would be empty.","Check for empty/undefined inputs feeding a dynamic id template string."],"exampleFix":"// before\nconst id = `schedule-${config.name ?? ''}`.toLowerCase(); // could be 'schedule-'\nschedules.create({ id, agentId, prompt, cron });\n\n// after\nconst slug = slugify(config.name ?? '');\nif (!slug) throw new Error('config.name must contain alphanumeric characters');\nschedules.create({ id: slug, agentId, prompt, cron });","handlingStrategy":"validation","validationCode":"function isValidScheduleId(raw) {\n  return typeof raw === 'string' && /[a-z0-9]/i.test(raw);\n}\nif (!isValidScheduleId(id)) throw new Error(`Invalid schedule id: ${JSON.stringify(id)}`);","typeGuard":"function isNonEmptySlugId(id: unknown): id is string {\n  return typeof id === 'string' && /[a-zA-Z0-9]/.test(id);\n}","tryCatchPattern":"try {\n  await schedules.create({ id, ...input });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'SCHEDULES_INVALID_ID') {\n    throw new Error(`Schedule id \"${input.id ?? ''}\" normalizes to empty; use an id with alphanumeric characters`);\n  }\n  throw e;\n}","preventionTips":["Ids must contain at least one alphanumeric character after slugification.","Do not pass prefix-only ids like 'agent_'; the prefix is added automatically.","Validate dynamic/template-generated ids before calling create; fall back to a UUID when the slug would be empty."],"tags":["schedules","validation","slugify","user-error"],"backgroundTag":"invalid-identifier","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}