mastra-ai/mastra · error · HTTPException
Version with id ${from} not found
Error message
Version with id ${from} not found What it means
Thrown by the revert/compare handler when getVersion(from) returns null: the 'from' version id supplied in the request does not exist. 404 HTTPException; scope checks on the block have already passed, so only the version id is wrong.
Source
Thrown at packages/server/src/server/handlers/prompt-block-versions.ts:460
tags: ['Prompt Block Versions'],
handler: async ({ mastra, promptBlockId, from, to, requestContext }) => {
try {
const storage = mastra.getStorage();
if (!storage) {
throw new HTTPException(500, { message: 'Storage is not configured' });
}
const promptBlockStore = await storage.getStore('promptBlocks');
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(View on GitHub (pinned to 75dd419e61)
Solutions
- Re-fetch the block's version list and use an existing versionId as 'from'.
- Check the version wasn't deleted by the delete-version route or cleanup jobs.
- Confirm both client and server point at the same storage database.
Defensive patterns
Strategy: validation
Validate before calling
const versions = await getBlockVersions(promptBlockId);
if (!versions.some(v => v.id === from)) {
throw new Error(`'from' version ${from} not found on block ${promptBlockId}`);
} Type guard
function resolveFrom(versions: { id: string }[], from: string): string | null {
return versions.some(v => v.id === from) ? from : null;
} Try / catch
try {
await revertVersions(promptBlockId, from, to);
} catch (e) {
if (e.status === 404 && e.message.includes('with id ' + from)) {
// refetch version list and pick an existing 'from'
}
throw e;
} Prevention
- Refresh the version list before any diff/revert call.
- Prune stale version ids from persisted UI state.
- Confirm environment/database alignment between client and server.
When it happens
Trigger: Requesting a version diff/revert with a from versionId that was deleted or never existed under this storage.
Common situations: Reverting to an old version that a teammate already pruned, stale UI state listing versions, or ids copied from logs of another environment.
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 ${to} not found
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/328797a4eb8837ca.
Report an issue: GitHub.