{"record":{"id":"276c3b689fcc870b","repo":"mastra-ai/mastra","slug":"version-with-id-to-not-found-276c3b","errorCode":null,"errorMessage":"Version with id ${to} not found","messagePattern":"Version with id (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/prompt-block-versions.ts","lineNumber":470,"sourceCode":"      if (!promptBlockStore) {\n        throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n      }\n      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","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/prompt-block-versions.ts#L452-L488","documentation":"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.","triggerScenarios":"Diff/revert request where the 'to' versionId is absent from storage (never created, already deleted, or wrong database).","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const versions = await getBlockVersions(promptBlockId);\nif (!versions.some(v => v.id === to)) {\n  throw new Error(`'to' version ${to} not found on block ${promptBlockId}`);\n}","typeGuard":"function resolveTo(versions: { id: string }[], to: string): string | null {\n  return versions.some(v => v.id === to) ? to : null;\n}","tryCatchPattern":"try {\n  await revertVersions(promptBlockId, from, to);\n} catch (e) {\n  if (e.status === 404 && e.message.includes('with id ' + to)) {\n    // refetch versions and choose an existing 'to'\n  }\n  throw e;\n}","preventionTips":["Fetch fresh version lists before comparisons.","Handle concurrent deletes: refresh and retry once with valid ids.","Do not reuse version ids from other environments."],"tags":["http-404","rest-api","versions","not-found"],"backgroundTag":"resource-not-found-404","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}