{"record":{"id":"2d0454ffcea8eb37","repo":"mastra-ai/mastra","slug":"could-not-derive-scorer-definition-id-from-name-p","errorCode":null,"errorMessage":"Could not derive scorer definition ID from name. Please provide an explicit id.","messagePattern":"Could not derive scorer definition ID from name\\. Please provide an explicit id\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"packages/server/src/server/handlers/stored-scorers.ts","lineNumber":165,"sourceCode":"    requestContext,\n  }) => {\n    try {\n      const storage = mastra.getStorage();\n\n      if (!storage) {\n        throw new HTTPException(500, { message: 'Storage is not configured' });\n      }\n\n      const scorerStore = await storage.getStore('scorerDefinitions');\n      if (!scorerStore) {\n        throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });\n      }\n\n      // Derive ID from name if not explicitly provided\n      const id = providedId || toSlug(name);\n\n      if (!id) {\n        throw new HTTPException(400, {\n          message: 'Could not derive scorer definition ID from name. Please provide an explicit id.',\n        });\n      }\n\n      // Check if scorer definition with this ID already exists\n      const existing = await scorerStore.getById(id);\n      if (existing) {\n        throw new HTTPException(409, { message: `Scorer definition with id ${id} already exists` });\n      }\n\n      await scorerStore.create({\n        scorerDefinition: {\n          id,\n          authorId,\n          metadata: scopeStoredResourceMetadata(metadata, await getStoredResourceScope(mastra, requestContext)),\n          name,\n          description,\n          type,","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-scorers.ts#L147-L183","documentation":"The create handler derives the scorer id via `providedId || toSlug(name)` and throws HTTP 400 when both produce an empty id — i.e. no explicit id was supplied and the name slugifies to an empty string (name empty or composed solely of characters stripped by the slugifier).","triggerScenarios":"POST create scorer with an omitted `id` and a `name` that is `''`, whitespace, or all non-slug characters (e.g. `\"!!!\"`, `\"---\"`), or a missing `name` entirely.","commonSituations":"Form submissions where name validation happens only in the UI and API callers skip it; international-language names whose characters are stripped by the ASCII slugger; automated scripts sending null/empty name.","solutions":["Pass an explicit `id` in the request body when the name may not slugify cleanly.","Send a non-empty name containing alphanumeric characters (e.g. transliterate non-ASCII names).","Validate on the client that `name.trim()` is non-empty and yields at least one [a-z0-9-] character before calling the API."],"exampleFix":"// before\ncreateScorer({ name: '!!' }); // 400: empty slug\n\n// after\ncreateScorer({ id: 'quality-check', name: 'Quality Check' });","handlingStrategy":"validation","validationCode":"function canDeriveId(name?: string, id?: string): boolean {\n  if (id && id.trim()) return true;\n  const slug = (name ?? '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');\n  return slug.length > 0;\n}\nif (!canDeriveId(body.name, body.id)) throw new Error('Provide an explicit id or an alphanumeric name.');","typeGuard":"function hasValidScorerName(input: { id?: string; name?: string }): input is { id?: string; name: string } {\n  return typeof input.name === 'string' && /[a-z0-9]/i.test(input.name);\n}","tryCatchPattern":"try {\n  await createScorer({ name });\n} catch (e) {\n  if (e.status === 400) throw new Error('Name did not produce a valid id — supply an explicit id.');\n  throw e;\n}","preventionTips":["Always send an explicit id for names containing non-ASCII or symbol-only characters","Validate server-side in your own API layer before proxying to Mastra","Mirror the slug rule (lowercase [a-z0-9-]) in form validation"],"tags":["http-400","validation","input","rest-api"],"backgroundTag":"invalid-request-input","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}