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
- 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.
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
- 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
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
- Agent ID is required
- Could not derive MCP client ID from name. Please provide an
- Could not derive skill ID from name. Please provide an expli
- Argument "${key}" is required
- Invalid request index, indexName and positive dimension numb
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/2d0454ffcea8eb37.
Report an issue: GitHub.