mastra-ai/mastra · error
Scorer definition with id ${id} not found
Error message
Scorer definition with id ${id} not found What it means
The in-memory scorer-definitions storage update() throws when no scorer definition with the given id exists. Updates only apply to existing records, so an unknown id is surfaced as an explicit error instead of a silent no-op.
Source
Thrown at packages/core/src/storage/domains/scorer-definitions/inmemory.ts:97
await this.createVersion({
id: versionId,
scorerDefinitionId: scorerDefinition.id,
versionNumber: 1,
...snapshotConfig,
changedFields: Object.keys(snapshotConfig),
changeMessage: 'Initial version',
});
// Return the thin scorer record
return this.deepCopyScorer(newScorer);
}
async update(input: StorageUpdateScorerDefinitionInput): Promise<StorageScorerDefinitionType> {
const { id, ...updates } = input;
const existingScorer = this.db.scorerDefinitions.get(id);
if (!existingScorer) {
throw new Error(`Scorer definition with id ${id} not found`);
}
// Separate metadata fields from config fields
const { authorId, activeVersionId, metadata, status } = updates;
// Update metadata fields on the scorer record
const updatedScorer: StorageScorerDefinitionType = {
...existingScorer,
...(authorId !== undefined && { authorId }),
...(activeVersionId !== undefined && { activeVersionId }),
...(status !== undefined && { status: status as StorageScorerDefinitionType['status'] }),
...(metadata !== undefined && {
metadata: { ...existingScorer.metadata, ...metadata },
}),
updatedAt: new Date(),
};
// Save the updated scorer recordView on GitHub (pinned to 75dd419e61)
Solutions
- Create the scorer definition before updating it.
- Verify the id exists via list()/get before calling update, and handle the missing branch.
- Use the same storage instance for create and update (in-memory state is per-instance).
- Confirm you're not confusing a scorer definition id with a version id.
Example fix
// before
await storage.scorerDefinitions.update({ id: 'helpfulness', status: 'active' });
// after
const { scorers } = await storage.scorerDefinitions.list();
if (scorers.some(s => s.id === 'helpfulness')) {
await storage.scorerDefinitions.update({ id: 'helpfulness', status: 'active' });
} Defensive patterns
Strategy: try-catch
Validate before calling
const { scorers } = await storage.scorerDefinitions.list({ perPage: false });
if (!scorers.some(s => s.id === id)) {
throw new Error(`scorer definition ${id} not found; create it before updating`);
} Type guard
function scorerExists(scorers: { id: string }[], id: string): boolean {
return scorers.some(s => s.id === id);
} Try / catch
try {
return await storage.scorerDefinitions.update({ id, ...updates });
} catch (e) {
if (e instanceof Error && e.message === `Scorer definition with id ${id} not found`) {
throw new Error(`Scorer ${id} missing in this storage instance; check create step and instance identity`);
}
throw e;
} Prevention
- Ensure the create step completes before any update/activate step (check ordering in setup code).
- Don't confuse scorer definition ids with scorer version ids.
- Verify you are operating on the same in-memory storage instance that holds the definition.
- Validate ids from config/env against list() output at startup.
When it happens
Trigger: Calling update({ id: 's1', status: 'active' }) for an id never created, deleted, or living in a different storage instance; passing a version id or scorer id from the wrong namespace.
Common situations: Activating a scorer version whose definition creation step failed or was skipped; environment mismatch (dev ids used against a fresh test store); stale ids cached from a previous process.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Agent with id ${id} not found
- Dataset not found: ${args.id}
- Dataset not found: ${args.datasetId}
- Item not found: ${args.id}
- MCP client with id ${id} not found
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/a8f50b986bdd0226.
Report an issue: GitHub.