{"record":{"id":"d8c531d574342968","repo":"mastra-ai/mastra","slug":"favorites-storage-domain-is-not-available-d8c531","errorCode":null,"errorMessage":"Favorites storage domain is not available","messagePattern":"Favorites storage domain is not available","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"critical","filePath":"packages/server/src/server/handlers/stored-skill-favorites.ts","lineNumber":25,"sourceCode":"import { assertReadAccess, getCallerAuthorId } from './authorship';\nimport { requireBuilderFeature } from './editor-builder';\nimport { handleError } from './error';\n\n/**\n * Resolves the storage and favorites domains, throwing 500 if unavailable.\n */\nasync function getFavoritesContext(mastra: Parameters<typeof requireBuilderFeature>[0]) {\n  const storage = mastra.getStorage();\n  if (!storage) {\n    throw new HTTPException(500, { message: 'Storage is not configured' });\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  const favoritesStore = await storage.getStore('favorites');\n  if (!favoritesStore) {\n    throw new HTTPException(500, { message: 'Favorites storage domain is not available' });\n  }\n  return { skillStore, favoritesStore };\n}\n\n/**\n * PUT /stored/skills/:storedSkillId/favorite\n */\nexport const FAVORITE_STORED_SKILL_ROUTE = createRoute({\n  method: 'PUT',\n  path: '/stored/skills/:storedSkillId/favorite',\n  responseType: 'json',\n  pathParamSchema: storedSkillIdPathParams,\n  responseSchema: favoriteToggleResponseSchema,\n  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',","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-skill-favorites.ts#L7-L43","documentation":"getFavoritesContext resolves the storage adapter's 'skills' and 'favorites' domains for the stored-skill favorites routes. When mastra.getStorage() exists but storage.getStore('favorites') returns nothing, the server cannot read or write favorites and throws this HTTPException with status 500. It is a server-side configuration/deployment problem, not a client mistake: the favorites storage domain was never registered or failed to initialize.","triggerScenarios":"Any request to PUT or DELETE /stored/skills/:storedSkillId/favorite (or the favorites-filter path of the stored-skills list) when the configured storage adapter does not expose a 'favorites' store — e.g. getStore('favorites') resolves to undefined because the storage class doesn't implement the favorites domain or wasn't registered.","commonSituations":"Running with a storage backend (in-memory, older LibSQL/Pg config, custom adapter) that predates the favorites domain; a custom MastraStorage implementation missing the favorites store; connecting to a database whose schema/migrations for favorites were never applied; swapping storage config in one environment but not another.","solutions":["Configure a storage adapter that implements the favorites domain (e.g. current @mastra/libsql or @mastra/pg) in new Mastra({...storage})","Run the storage schema setup/migrations so the favorites tables exist for the configured backend","Verify storage.getStore('favorites') returns a store in a small script against your deployed storage config","If using a custom storage class, implement and register the favorites store in getStore()"],"exampleFix":"// before\nnew Mastra({ storage: new InMemoryStorage() });\n\n// after\nimport { LibSQLStore } from '@mastra/libsql';\nnew Mastra({ storage: new LibSQLStore({ url: process.env.DATABASE_URL }) });","handlingStrategy":"fallback","validationCode":"const storage = mastra.getStorage();\nconst favoritesStore = storage ? await storage.getStore('favorites') : undefined;\nif (!favoritesStore) {\n  console.warn('Favorites domain unavailable; hiding favorites UI');\n}","typeGuard":"function hasFavoritesDomain(s: unknown): s is { getStore(d: 'favorites'): Promise<unknown> } {\n  return !!s && typeof (s as any).getStore === 'function';\n}","tryCatchPattern":"try {\n  await api.put(`/stored/skills/${id}/favorite`);\n} catch (e) {\n  if (isHttpError(e) && e.status === 500 && /Favorites storage domain/.test(e.message)) {\n    disableFavoritesFeature(); // degrade gracefully\n  } else throw e;\n}","preventionTips":["Pin a storage adapter that explicitly supports the favorites domain","Add a boot-time health check asserting getStore('skills') and getStore('favorites') both resolve","Keep @mastra/core and storage package versions aligned"],"tags":["storage","server","configuration","favorites"],"backgroundTag":"storage-domain-unavailable","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}