mastra-ai/mastra · warning · HTTPException

Could not derive scorer definition ID from name. Please prov

Error message

Could not derive scorer definition ID from name. Please provide an explicit id.

What it means

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).

Source

Thrown at packages/server/src/server/handlers/stored-scorers.ts:165

    requestContext,
  }) => {
    try {
      const storage = mastra.getStorage();

      if (!storage) {
        throw new HTTPException(500, { message: 'Storage is not configured' });
      }

      const scorerStore = await storage.getStore('scorerDefinitions');
      if (!scorerStore) {
        throw new HTTPException(500, { message: 'Scorer definitions storage domain is not available' });
      }

      // Derive ID from name if not explicitly provided
      const id = providedId || toSlug(name);

      if (!id) {
        throw new HTTPException(400, {
          message: 'Could not derive scorer definition ID from name. Please provide an explicit id.',
        });
      }

      // Check if scorer definition with this ID already exists
      const existing = await scorerStore.getById(id);
      if (existing) {
        throw new HTTPException(409, { message: `Scorer definition with id ${id} already exists` });
      }

      await scorerStore.create({
        scorerDefinition: {
          id,
          authorId,
          metadata: scopeStoredResourceMetadata(metadata, await getStoredResourceScope(mastra, requestContext)),
          name,
          description,
          type,

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Pass an explicit `id` in the request body when the name may not slugify cleanly.
  2. Send a non-empty name containing alphanumeric characters (e.g. transliterate non-ASCII names).
  3. Validate on the client that `name.trim()` is non-empty and yields at least one [a-z0-9-] character before calling the API.

Example fix

// before
createScorer({ name: '!!' }); // 400: empty slug

// after
createScorer({ id: 'quality-check', name: 'Quality Check' });
Defensive patterns

Strategy: validation

Validate before calling

function canDeriveId(name?: string, id?: string): boolean {
  if (id && id.trim()) return true;
  const slug = (name ?? '').toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '');
  return slug.length > 0;
}
if (!canDeriveId(body.name, body.id)) throw new Error('Provide an explicit id or an alphanumeric name.');

Type guard

function hasValidScorerName(input: { id?: string; name?: string }): input is { id?: string; name: string } {
  return typeof input.name === 'string' && /[a-z0-9]/i.test(input.name);
}

Try / catch

try {
  await createScorer({ name });
} catch (e) {
  if (e.status === 400) throw new Error('Name did not produce a valid id — supply an explicit id.');
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/2d0454ffcea8eb37. Report an issue: GitHub.