{"record":{"id":"3fa7a5269fff17bd","repo":"mastra-ai/mastra","slug":"version-with-id-to-not-found-for-prompt-block","errorCode":null,"errorMessage":"Version with id ${to} not found for prompt block ${promptBlockId}","messagePattern":"Version with id (.+?) not found for prompt block (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/prompt-block-versions.ts","lineNumber":473,"sourceCode":"      const promptBlock = await promptBlockStore.getById(promptBlockId);\n      assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n      const fromVersion = await promptBlockStore.getVersion(from);\n      if (!fromVersion) {\n        throw new HTTPException(404, { message: `Version with id ${from} not found` });\n      }\n      if (fromVersion.blockId !== promptBlockId) {\n        throw new HTTPException(404, {\n          message: `Version with id ${from} not found for prompt block ${promptBlockId}`,\n        });\n      }\n\n      const toVersion = await promptBlockStore.getVersion(to);\n      if (!toVersion) {\n        throw new HTTPException(404, { message: `Version with id ${to} not found` });\n      }\n      if (toVersion.blockId !== promptBlockId) {\n        throw new HTTPException(404, {\n          message: `Version with id ${to} not found for prompt block ${promptBlockId}`,\n        });\n      }\n\n      const fromConfig = extractConfigFromVersion(\n        fromVersion as unknown as Record<string, unknown>,\n        SNAPSHOT_CONFIG_FIELDS,\n      );\n      const toConfig = extractConfigFromVersion(\n        toVersion as unknown as Record<string, unknown>,\n        SNAPSHOT_CONFIG_FIELDS,\n      );\n\n      const diffs = computeVersionDiffs(fromConfig, toConfig);\n\n      return {\n        diffs,\n        fromVersion,","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/prompt-block-versions.ts#L455-L491","documentation":"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.","triggerScenarios":"Diff/revert request pairing prompt block A in the path with a 'to' version that belongs to prompt block B.","commonSituations":"Diff tools comparing versions across two blocks, cached 'to' selection from a previous block, or URL construction mixing ids from different API responses.","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."],"exampleFix":"// before\nawait post(`/prompt-blocks/${blockA.id}/revert`, { from, to: versionFromBlockB });\n// after\nconst versions = await get(`/prompt-blocks/${blockA.id}/versions`);\nconst ids = new Set(versions.map(v => v.id));\nif (ids.has(from) && ids.has(to)) await post(`/prompt-blocks/${blockA.id}/revert`, { from, to });","handlingStrategy":"type-guard","validationCode":"const versions = await getBlockVersions(promptBlockId);\nif (!versions.some(v => v.id === to)) {\n  throw new Error(`'to' version ${to} does not belong to block ${promptBlockId}`);\n}","typeGuard":"function bothOwned(versions: { id: string; blockId: string }[], from: string, to: string): boolean {\n  return [from, to].every(id => versions.some(v => v.id === id && v.blockId === versions[0].blockId));\n}","tryCatchPattern":"try {\n  await revertVersions(promptBlockId, from, to);\n} catch (e) {\n  if (e.status === 404 && e.message.includes('not found for prompt block')) {\n    // 'to' belongs to another block — reselect within this block\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["http-404","rest-api","id-mismatch","versions"],"backgroundTag":"resource-not-found-404","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}