mastra-ai/mastra · error · HTTPException
Version with id ${versionId} not found
Error message
Version with id ${versionId} not found What it means
Thrown as HTTP 404 when getVersion(versionId) returns no row for the requested version id. Storage and store are healthy; the version identifier is unknown to this database.
Source
Thrown at packages/server/src/server/handlers/scorer-versions.ts:203
description: 'Returns a specific version of a scorer by its version ID',
tags: ['Scorer Versions'],
handler: async ({ mastra, scorerId, versionId, 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' });
}
const version = await scorerStore.getVersion(versionId);
if (!version) {
throw new HTTPException(404, { message: `Version with id ${versionId} not found` });
}
if (version.scorerDefinitionId !== scorerId) {
throw new HTTPException(404, {
message: `Version with id ${versionId} not found for scorer ${scorerId}`,
});
}
const scorer = await scorerStore.getById(scorerId);
assertStoredResourceScope(scorer, await getStoredResourceScope(mastra, requestContext));
return version;
} catch (error) {
return handleError(error, 'Error getting scorer version');
}
},
});
/**View on GitHub (pinned to 75dd419e61)
Solutions
- List the scorer's versions (GET /api/scorers/{scorerId}/versions) and use a valid versionId
- Confirm client and server point at the same database/environment
- Check whether a retention policy deleted the version; adjust retention or stop caching old ids
- Fix the typo in the versionId
Defensive patterns
Strategy: try-catch
Validate before calling
const versions = await (await fetch(`/api/scorers/${scorerId}/versions`)).json();
if (!versions.results?.some(v => v.id === versionId)) {
throw new Error(`Unknown versionId ${versionId} for scorer ${scorerId}`);
} Type guard
function versionExists(versionId: string, versions: { id: string }[]): boolean {
return versions.some(v => v.id === versionId);
} Try / catch
const res = await fetch(`/api/scorers/${scorerId}/versions/${versionId}`);
if (res.status === 404) {
// list versions, pick a valid id or re-resolve from the scorer's activeVersionId
} Prevention
- Fetch version ids from the list endpoint rather than persisting them long-term
- Account for retention limits that may delete old versions
- Keep environment-specific ids out of shared config
- Check version.scorerDefinitionId match logic when iterating versions across scorers
When it happens
Trigger: GET /api/scorers/{scorerId}/versions/{versionId} with a versionId that does not exist — fabricated id, id from another environment, or the version was pruned by retention limits (enforceRetentionLimit).
Common situations: Retaining stale version ids in a client after retention cleanup deleted old versions; ids copied across dev/staging databases; referencing versions before any version was created for the scorer.
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
- Conversation ${conversationId} was not found
- Stored response ${body.previous_response_id} was not found
- Scorer with id ${scorerId} not found
- AcpAgent does not support resuming suspended generate calls
- AcpAgent does not support resuming suspended stream calls
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/693a2cd5af484d6c.
Report an issue: GitHub.