mastra-ai/mastra · error · HTTPException
Version with id ${to} not found
Error message
Version with id ${to} not found What it means
Thrown when getVersion(to) returns null in the from/to (diff/revert) handler: the 'to' version id does not exist. The handler validates 'from' first, then 'to', each with an individualized 404 message.
Source
Thrown at packages/server/src/server/handlers/prompt-block-versions.ts:470
if (!promptBlockStore) {
throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });
}
const promptBlock = await promptBlockStore.getById(promptBlockId);
assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));
const fromVersion = await promptBlockStore.getVersion(from);
if (!fromVersion) {
throw new HTTPException(404, { message: `Version with id ${from} not found` });
}
if (fromVersion.blockId !== promptBlockId) {
throw new HTTPException(404, {
message: `Version with id ${from} not found for prompt block ${promptBlockId}`,
});
}
const toVersion = await promptBlockStore.getVersion(to);
if (!toVersion) {
throw new HTTPException(404, { message: `Version with id ${to} not found` });
}
if (toVersion.blockId !== promptBlockId) {
throw new HTTPException(404, {
message: `Version with id ${to} not found for prompt block ${promptBlockId}`,
});
}
const fromConfig = extractConfigFromVersion(
fromVersion as unknown as Record<string, unknown>,
SNAPSHOT_CONFIG_FIELDS,
);
const toConfig = extractConfigFromVersion(
toVersion as unknown as Record<string, unknown>,
SNAPSHOT_CONFIG_FIELDS,
);
const diffs = computeVersionDiffs(fromConfig, toConfig);
View on GitHub (pinned to 75dd419e61)
Solutions
- Fetch the block's versions and choose an existing id for 'to'.
- Verify the target version still exists (it may have been deleted).
- Ensure the client and server use the same storage backend/environment.
Defensive patterns
Strategy: validation
Validate before calling
const versions = await getBlockVersions(promptBlockId);
if (!versions.some(v => v.id === to)) {
throw new Error(`'to' version ${to} not found on block ${promptBlockId}`);
} Type guard
function resolveTo(versions: { id: string }[], to: string): string | null {
return versions.some(v => v.id === to) ? to : null;
} Try / catch
try {
await revertVersions(promptBlockId, from, to);
} catch (e) {
if (e.status === 404 && e.message.includes('with id ' + to)) {
// refetch versions and choose an existing 'to'
}
throw e;
} Prevention
- Fetch fresh version lists before comparisons.
- Handle concurrent deletes: refresh and retry once with valid ids.
- Do not reuse version ids from other environments.
When it happens
Trigger: Diff/revert request where the 'to' versionId is absent from storage (never created, already deleted, or wrong database).
Common situations: Comparing against a version that was removed concurrently, typos in the to id, or pointing the client at a fresh database while using ids from an old one.
Related errors
- ACP connection is not initialized
- Model "${this.options.model}" is not available. Available mo
- ClaudeSDKAgent resumeData.sessionId must be a string.
- ClaudeSDKAgent resumeData.continue must be true when provide
- Version with id ${from} not found
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/276c3b689fcc870b.
Report an issue: GitHub.