{"record":{"id":"495f5c13dc42618d","repo":"mastra-ai/mastra","slug":"favorites-storage-domain-is-not-available","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-agent-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 agentStore = await storage.getStore('agents');\n  if (!agentStore) {\n    throw new HTTPException(500, { message: 'Agents 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 { agentStore, favoritesStore };\n}\n\n/**\n * PUT /stored/agents/:storedAgentId/favorite\n */\nexport const FAVORITE_STORED_AGENT_ROUTE = createRoute({\n  method: 'PUT',\n  path: '/stored/agents/:storedAgentId/favorite',\n  responseType: 'json',\n  pathParamSchema: storedAgentIdPathParams,\n  responseSchema: favoriteToggleResponseSchema,\n  summary: 'Favorite a stored agent',\n  description: 'Marks the stored agent as favorited by the calling user. Idempotent.',\n  tags: ['Stored Agents'],\n  requiresAuth: true,\n  requiresPermission: 'stored-agents:read',","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-agent-favorites.ts#L7-L43","documentation":"getFavoritesContext also requires the 'favorites' storage domain, requested via storage.getStore('favorites'). If that store is unavailable on the configured adapter, it throws HTTPException 500. Favorites persistence is a separate domain from agents and must be present even when agents storage works.","triggerScenarios":"Calling a favorites endpoint where storage and the agents store resolve, but storage.getStore('favorites') returns null (adapter lacking the favorites domain).","commonSituations":"Older storage adapter versions predating the favorites domain; adapters that implement agents but not favorites; schema not migrated after upgrading core/server packages.","solutions":["Upgrade the storage adapter to a version supporting the favorites domain","Run database migrations so favorites tables exist","Add a startup check asserting all required domains (agents, favorites) are available","Disable the favorites builder feature if the storage backend can't support it"],"exampleFix":"// before\nstorage: oldAdapter v1 // lacks favorites store\n// after\npnpm up @mastra/libsql@latest && run migrations","handlingStrategy":"validation","validationCode":"const storage = mastra.getStorage();\nif (storage && !(await storage.getStore('favorites'))) {\n  throw new Error('Storage adapter does not provide the favorites domain');\n}","typeGuard":"async function hasFavoritesDomain(storage: MastraStorage): Promise<boolean> {\n  return (await storage.getStore('favorites')) != null;\n}","tryCatchPattern":"try {\n  await favoritesApi.list();\n} catch (e) {\n  if (e.status === 500 && /Favorites storage domain/.test(e.message)) {\n    runMigrationsAndAlert();\n  } else throw e;\n}","preventionTips":["Run migrations after every adapter/core upgrade","Check adapter release notes for favorites domain support before adopting it","Gate the favorites feature behind a storage capability check"],"tags":["storage","storage-domain","favorites","http-500"],"backgroundTag":"storage-domain-missing","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}