mastra-ai/mastra · error · HTTPException
Version with id ${to} not found for prompt block ${promptBlo
Error message
Version with id ${to} not found for prompt block ${promptBlockId} What it means
Thrown when the 'to' version exists but is owned by a different prompt block (toVersion.blockId !== promptBlockId). Returned as a masked 404 for the same information-hiding reason as the other mismatch errors. The diff/revert operation requires both versions to belong to the addressed block.
Source
Thrown at packages/server/src/server/handlers/prompt-block-versions.ts:473
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);
return {
diffs,
fromVersion,View on GitHub (pinned to 75dd419e61)
Solutions
- Select 'to' only from the target block's version list.
- Correct the promptBlockId in the path if the 'to' version's owner is the intended block.
- Add client-side validation that both from and to versions share the block's id before issuing the request.
Example fix
// before
await post(`/prompt-blocks/${blockA.id}/revert`, { from, to: versionFromBlockB });
// after
const versions = await get(`/prompt-blocks/${blockA.id}/versions`);
const ids = new Set(versions.map(v => v.id));
if (ids.has(from) && ids.has(to)) await post(`/prompt-blocks/${blockA.id}/revert`, { from, to }); Defensive patterns
Strategy: type-guard
Validate before calling
const versions = await getBlockVersions(promptBlockId);
if (!versions.some(v => v.id === to)) {
throw new Error(`'to' version ${to} does not belong to block ${promptBlockId}`);
} Type guard
function bothOwned(versions: { id: string; blockId: string }[], from: string, to: string): boolean {
return [from, to].every(id => versions.some(v => v.id === id && v.blockId === versions[0].blockId));
} Try / catch
try {
await revertVersions(promptBlockId, from, to);
} catch (e) {
if (e.status === 404 && e.message.includes('not found for prompt block')) {
// 'to' belongs to another block — reselect within this block
}
throw e;
} Prevention
- Validate that from and to resolve from the same block before calling.
- In diff UIs, scope version pickers to the currently selected block only.
- Log and alert on cross-block id pairs found in client telemetry.
When it happens
Trigger: Diff/revert request pairing prompt block A in the path with a 'to' version that belongs to prompt block B.
Common situations: Diff tools comparing versions across two blocks, cached 'to' selection from a previous block, or URL construction mixing ids from different API responses.
Related errors
- Version with id ${from} not found for prompt block ${promptB
- 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
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/3fa7a5269fff17bd.
Report an issue: GitHub.