{"record":{"id":"8326cd2245f49a32","repo":"mastra-ai/mastra","slug":"stored-skill-with-id-storedskillid-not-found","errorCode":null,"errorMessage":"Stored skill with id ${storedSkillId} not found","messagePattern":"Stored skill with id (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/stored-skill-favorites.ts","lineNumber":57,"sourceCode":"  summary: 'Favorite a stored skill',\n  description: 'Marks the stored skill as favorited by the calling user. Idempotent.',\n  tags: ['Stored Skills'],\n  requiresAuth: true,\n  requiresPermission: 'stored-skills:read',\n  handler: async ({ mastra, requestContext, storedSkillId }) => {\n    try {\n      await requireBuilderFeature(mastra, 'favorites');\n\n      const callerId = getCallerAuthorId(requestContext);\n      if (!callerId) {\n        throw new HTTPException(401, { message: 'Authentication required' });\n      }\n\n      const { skillStore, favoritesStore } = await getFavoritesContext(mastra);\n\n      const skill = await skillStore.getByIdResolved(storedSkillId);\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      // Throws 404 if the caller cannot read the skill (private + not owner/admin).\n      assertReadAccess({ requestContext, resource: 'stored-skills', resourceId: storedSkillId, record: skill });\n\n      const result = await favoritesStore.favorite({\n        userId: callerId,\n        entityType: 'skill',\n        entityId: storedSkillId,\n      });\n      return result;\n    } catch (error) {\n      return handleError(error, 'Error favoriting stored skill');\n    }\n  },\n});\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-skill-favorites.ts#L39-L75","documentation":"When favoriting, the handler loads the stored skill via skillStore.getByIdResolved(storedSkillId). If no skill with that id exists (or has been deleted), it throws HTTPException 404 with a message embedding the requested id. The id is interpolated into the message, so it is safe to log — the resource genuinely does not exist for lookup purposes.","triggerScenarios":"PUT /stored/skills/:storedSkillId/favorite with an id that was never created, a stale/deleted id, a typo'd id, or an id from a different environment's database.","commonSituations":"Bookmarks/clients caching skill ids after the skill was deleted; copying ids between dev/staging/prod databases; URL-encoding or whitespace mistakes in the path parameter; hard-coded ids in tests or scripts.","solutions":["Verify the storedSkillId exists via GET /stored/skills (list) or the skill's canonical URL and use the correct id","Re-fetch skill ids from the same environment/database the API is pointed at","Handle 404 in the client by refreshing the local list and dropping stale favorites","Check for typos, trailing whitespace, or truncation in the id path parameter"],"exampleFix":"// before\nawait api.put(`/stored/skills/${cachedId}/favorite`);\n\n// after\nconst skills = await api.get('/stored/skills?authorId=me');\nif (!skills.some(s => s.id === cachedId)) cachedId = null; // refresh before favoriting","handlingStrategy":"validation","validationCode":"const exists = (await api.get('/stored/skills')).skills.some(s => s.id === storedSkillId);\nif (!exists) throw new Error(`Skip favoriting: ${storedSkillId} not found`);","typeGuard":"function isKnownSkill(skills: { id: string }[], id: string): boolean {\n  return skills.some(s => s.id === id);\n}","tryCatchPattern":"try {\n  await api.put(`/stored/skills/${id}/favorite`);\n} catch (e) {\n  if (isHttpError(e) && e.status === 404) { refreshSkillList(); return; }\n  throw e;\n}","preventionTips":["Always source skill ids from a live list call, never hard-code them","Purge client-side caches when skills are deleted","Use environment-specific id books, not ids shared across envs"],"tags":["http-404","not-found","stored-skills","server"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}