{"record":{"id":"82cd1173e6d51276","repo":"mastra-ai/mastra","slug":"prompt-block-with-id-promptblockid-not-found","errorCode":null,"errorMessage":"Prompt block with id ${promptBlockId} not found","messagePattern":"Prompt block with id (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/prompt-block-versions.ts","lineNumber":60,"sourceCode":"  summary: 'List prompt block versions',\n  description: 'Returns a paginated list of all versions for a stored prompt block',\n  tags: ['Prompt Block Versions'],\n  handler: async ({ mastra, promptBlockId, page, perPage, orderBy, 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 promptBlock = await promptBlockStore.getById(promptBlockId);\n      if (!promptBlock) {\n        throw new HTTPException(404, { message: `Prompt block with id ${promptBlockId} not found` });\n      }\n      assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n      const result = await promptBlockStore.listVersions({\n        blockId: promptBlockId,\n        page,\n        perPage,\n        orderBy,\n      });\n\n      return result;\n    } catch (error) {\n      return handleError(error, 'Error listing prompt block versions');\n    }\n  },\n});\n\n/**","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/prompt-block-versions.ts#L42-L78","documentation":"The promptBlocks store was reachable, but getById(promptBlockId) found no record, so the handler returns HTTP 404 naming the missing id. This is a lookup miss, not a configuration problem.","triggerScenarios":"GET/POST a prompt-block-versions route with a promptBlockId that has no row in the promptBlocks store (deleted block, wrong id, or id from another environment/database).","commonSituations":"Stale ids cached in the playground after a database reset; pointing staging UI at a prod database or vice versa; typos or trimmed/uuid-mismatched ids in scripts.","solutions":["Verify the promptBlockId exists (e.g. list prompt blocks first and use an id from the response).","Check you are connected to the storage instance/database that actually contains the block.","Recreate the prompt block if it was deleted; handle 404 in the client UI gracefully."],"exampleFix":"// before\nconst versions = await fetch(`/api/prompt-blocks/${id}/versions`);\n// after\nconst list = await fetch('/api/prompt-blocks').then(r => r.json());\nif (!list.blocks.some(b => b.id === id)) throw new Error(`Unknown prompt block ${id}`);\nconst versions = await fetch(`/api/prompt-blocks/${id}/versions`);","handlingStrategy":"try-catch","validationCode":"const blocks = await client.listPromptBlocks();\nif (!blocks.blocks.some(b => b.id === promptBlockId)) {\n  throw new Error(`Prompt block ${promptBlockId} does not exist in this storage`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const versions = await client.getPromptBlockVersions(id);\n} catch (e) {\n  if (e.status === 404 && e.message.includes('not found')) {\n    console.warn(`Prompt block ${id} missing; showing empty state`);\n    return [];\n  }\n  throw e;\n}","preventionTips":["Refresh cached prompt-block ids after database resets or environment switches.","Confirm the storage URL points at the environment that owns the block.","Handle 404 in UI flows instead of assuming ids are always valid."],"tags":["http-404","storage","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}