{"record":{"id":"ebd29e16d315067e","repo":"mastra-ai/mastra","slug":"stored-prompt-block-with-id-storedpromptblockid","errorCode":null,"errorMessage":"Stored prompt block with id ${storedPromptBlockId} not found","messagePattern":"Stored prompt block with id (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/stored-prompt-blocks.ts","lineNumber":125,"sourceCode":"  tags: ['Stored Prompt Blocks'],\n  requiresAuth: true,\n  handler: async ({ mastra, storedPromptBlockId, status, 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.getByIdResolved(storedPromptBlockId, { status });\n\n      if (!promptBlock) {\n        throw new HTTPException(404, { message: `Stored prompt block with id ${storedPromptBlockId} not found` });\n      }\n      assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n      const latestVersion = await promptBlockStore.getLatestVersion(storedPromptBlockId);\n\n      return { ...promptBlock, hasDraft: computeHasDraft(latestVersion, promptBlock.activeVersionId) };\n    } catch (error) {\n      return handleError(error, 'Error getting stored prompt block');\n    }\n  },\n});\n\n/**\n * POST /stored/prompt-blocks - Create a new stored prompt block\n */\nexport const CREATE_STORED_PROMPT_BLOCK_ROUTE = createRoute({\n  method: 'POST',\n  path: '/stored/prompt-blocks',","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-prompt-blocks.ts#L107-L143","documentation":"HTTP 404 thrown when promptBlockStore.getByIdResolved(id, { status }) finds no stored prompt block with the given id. The id is path-valid but no record matches in the configured storage, or it is not visible in the requested status/scope.","triggerScenarios":"GET /api/stored-prompt-blocks/:id where the id doesn't exist, was deleted, exists only under a different status than requested, or is outside the caller's stored-resource scope.","commonSituations":"Stale bookmarked id after a database reset; id copied from another environment; requesting status 'draft' when only 'active' exists; multi-tenant scope mismatch.","solutions":["List prompt blocks to confirm the id exists and copy it from the response","Drop or correct the status query parameter so the default resolution applies","Verify you are querying the environment/database that contains the block","Check resource scope — the block may exist but be hidden from your request context"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const store = await mastra.getStorage()?.getStore('promptBlocks');\nconst list = await store?.listResolved({ page: 0, perPage: 100 });\nif (!list?.results.some(b => b.id === id)) throw new Error(`prompt block ${id} not found`);","typeGuard":null,"tryCatchPattern":"try {\n  const block = await client.getStoredPromptBlock(id, { status });\n} catch (e) {\n  if (isHttpError(e, 404)) {\n    // refresh id from list endpoint; check status filter and scope\n  }\n}","preventionTips":["Copy ids from list responses, never from memory","Verify environment/database before debugging 404s","Clear status filters when unsure of block state","Account for resource-scope visibility"],"tags":["http-404","not-found","prompt-blocks","rest"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}