{"record":{"id":"6b5f008530937926","repo":"mastra-ai/mastra","slug":"version-with-id-versionid-not-found-6b5f00","errorCode":null,"errorMessage":"Version with id ${versionId} 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":194,"sourceCode":"  description: 'Returns a specific version of a prompt block by its version ID',\n  tags: ['Prompt Block Versions'],\n  handler: async ({ mastra, promptBlockId, versionId, requestContext }) => {\n    try {\n      const storage = mastra.getStorage();\n\n      if (!storage) {\n        throw new HTTPException(500, { message: 'Storage is not configured' });\n      }\n\n      const promptBlockStore = await storage.getStore('promptBlocks');\n      if (!promptBlockStore) {\n        throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n      }\n\n      const version = await promptBlockStore.getVersion(versionId);\n\n      if (!version) {\n        throw new HTTPException(404, { message: `Version with id ${versionId} not found` });\n      }\n\n      if (version.blockId !== promptBlockId) {\n        throw new HTTPException(404, {\n          message: `Version with id ${versionId} not found for prompt block ${promptBlockId}`,\n        });\n      }\n      const promptBlock = await promptBlockStore.getById(promptBlockId);\n      assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n      return version;\n    } catch (error) {\n      return handleError(error, 'Error getting prompt block version');\n    }\n  },\n});\n\n/**","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/prompt-block-versions.ts#L176-L212","documentation":"The handler fetches the version by versionId; if none exists it returns a 404 naming the version id. Note the lookup is done by versionId alone first, and the promptBlockId match is checked separately (error 2896), so this message strictly means the version id is unknown to the store.","triggerScenarios":"GET /stored/prompt-blocks/:promptBlockId/versions/:versionId where getVersion(versionId) returns null — the version was never created, was deleted, or the id is malformed.","commonSituations":"Retention limits deleting old versions that a client still references; ids copied from logs of another environment; referencing a version of a deleted prompt block.","solutions":["List current versions via GET /stored/prompt-blocks/:promptBlockId/versions and use an existing versionId.","Verify the version wasn't pruned by the retention policy (max versions) and raise the limit if history must be kept.","Confirm the id is complete and not truncated (uuid copy/paste errors).","Check you are querying the same storage/database where the version was created."],"exampleFix":"// before\nawait fetch(`/api/stored/prompt-blocks/${blockId}/versions/${guessedVersionId}`);\n// after\nconst { versions } = await fetch(`/api/stored/prompt-blocks/${blockId}/versions`).then(r => r.json());\nconst versionId = versions.find(v => v.changeMessage === 'initial')?.id;\nawait fetch(`/api/stored/prompt-blocks/${blockId}/versions/${versionId}`);","handlingStrategy":"validation","validationCode":"const { versions } = await fetch(`/api/stored/prompt-blocks/${blockId}/versions`).then(r => r.json());\nif (!versions.some(v => v.id === versionId)) throw new Error(`Version ${versionId} does not exist for block ${blockId}`);","typeGuard":"function isKnownVersionId(versions: { id: string }[], versionId: string): boolean {\n  return versions.some(v => v.id === versionId);\n}","tryCatchPattern":"try {\n  await fetchVersion(blockId, versionId);\n} catch (e) {\n  if (e.status === 404 && e.message.startsWith('Version with id')) {\n    const { versions } = await listVersions(blockId);\n    versionId = versions[0]?.id; // fall back to latest\n  } else throw e;\n}","preventionTips":["Fetch version ids from listVersions rather than storing them long-term.","Raise retention limits if old versions must remain addressable.","Validate uuid format before calling the API."],"tags":["http-404","not-found","versioning","rest"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}