{"record":{"id":"a34387629373d7b7","repo":"mastra-ai/mastra","slug":"stored-skill-with-id-storedskillid-not-found-a34387","errorCode":null,"errorMessage":"Stored skill with id ${storedSkillId} not found","messagePattern":"Stored skill with id (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"warning","filePath":"packages/server/src/server/handlers/stored-skills.ts","lineNumber":270,"sourceCode":"  tags: ['Stored Skills'],\n  requiresAuth: true,\n  handler: async ({ mastra, requestContext, storedSkillId }) => {\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 skillStore = await storage.getStore('skills');\n      if (!skillStore) {\n        throw new HTTPException(500, { message: 'Skills storage domain is not available' });\n      }\n\n      const skill = await skillStore.getByIdResolved(storedSkillId);\n\n      if (!skill) {\n        throw new HTTPException(404, { message: `Stored skill with id ${storedSkillId} not found` });\n      }\n      assertStoredResourceScope(skill, await getStoredResourceScope(mastra, requestContext));\n\n      assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n      return enrichOrStripFavorites(mastra, requestContext, 'skill', skill);\n    } catch (error) {\n      return handleError(error, 'Error getting stored skill');\n    }\n  },\n});\n\n/**\n * POST /stored/skills - Create a new stored skill\n */\nexport const CREATE_STORED_SKILL_ROUTE = createRoute({\n  method: 'POST',\n  path: '/stored/skills',","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-skills.ts#L252-L288","documentation":"This 404 is thrown by the GET stored-skill handler after `skillStore.getByIdResolved(storedSkillId)` returns null, meaning no stored skill record (plus resolvable version config) exists for the requested ID in the skills storage domain. The library throws it to signal a missing resource before scope/read-access checks run. It is a normal lookup miss, not an infrastructure failure.","triggerScenarios":"GET /api/stored-skills/:id where the id does not exist in the skills store; the skill was deleted by another user/process; the caller targets the wrong Mastra instance or storage backend; a typo'd or stale ID from a previous create call.","commonSituations":"Client cached an ID from a skill that was later deleted; environment points at an empty/different database (e.g. dev vs prod storage); ID was slugified differently than expected; testing against a fresh LibSQL/Postgres instance with no seeded skills.","solutions":["Verify the skill ID exists by listing stored skills (GET /api/stored-skills) and using an ID from that list","Check that the Mastra instance is configured with the same storage backend where the skill was created","Re-create the skill if it was deleted (POST /api/stored-skills) and use the returned ID","Handle the 404 in the client instead of retrying — it is a definitive miss"],"exampleFix":"// before\nconst skill = await fetch(`/api/stored-skills/${id}`).then(r => r.json());\n// after\nconst res = await fetch(`/api/stored-skills/${id}`);\nif (res.status === 404) {\n  console.warn(`Skill ${id} not found; listing available skills`);\n} else {\n  const skill = await res.json();\n}","handlingStrategy":"try-catch","validationCode":"const exists = async (id: string) =>\n  (await fetch(`/api/stored-skills/${id}`)).status !== 404;\nif (!(await exists(id))) throw new Error(`Skip: skill ${id} missing`);","typeGuard":"function isHttp404(e: unknown): e is { status: 404 } {\n  return typeof e === 'object' && e !== null && (e as any).status === 404;\n}","tryCatchPattern":"try {\n  const skill = await getStoredSkill(id);\n} catch (e) {\n  if (isHttp404(e)) {\n    console.warn(`Skill ${id} not found; refresh ID list`);\n    return null; // treat as recoverable miss\n  }\n  throw e;\n}","preventionTips":["Always source IDs from the list/create endpoints, never hand-build them","Cache skill IDs with a short TTL and revalidate on 404","Distinguish environments (staging vs prod) in client config so IDs match storage","Treat 404 as a terminal result — no retry"],"tags":["http-404","not-found","storage","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}