{"record":{"id":"d44c0bb657d69cea","repo":"mastra-ai/mastra","slug":"favorites-storage-domain-is-not-available-d44c0b","errorCode":null,"errorMessage":"Favorites storage domain is not available","messagePattern":"Favorites storage domain is not available","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/stored-agents.ts","lineNumber":289,"sourceCode":"      });\n\n      const scope = await getStoredResourceScope(mastra, requestContext);\n      const scopedMetadata = scopeStoredResourceMetadata(metadata, scope);\n\n      const callerId = getCallerAuthorId(requestContext);\n      const favoritesEnabled = await isBuilderFeatureEnabled(mastra, 'favorites');\n      const honoredStarredOnly = favoritesEnabled && favoritedOnly === true;\n      const favoriteSubjectId = pinFavoritedFor ?? callerId;\n\n      // `?favoritedOnly=true`: fetch caller's favorited IDs, then refilter + recompute total.\n      if (honoredStarredOnly) {\n        const effectivePerPage: number = perPage ?? 100;\n        if (!favoriteSubjectId) {\n          return { agents: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\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        const starredIds = await favoritesStore.listFavoritedIds({ userId: favoriteSubjectId, entityType: 'agent' });\n        if (starredIds.length === 0) {\n          return { agents: [], total: 0, page, perPage: effectivePerPage, hasMore: false };\n        }\n        const allMatching = await agentsStore.listResolved({\n          perPage: false,\n          orderBy,\n          status,\n          authorId: filter.kind === 'exact' ? filter.authorId : undefined,\n          metadata: scopedMetadata,\n          entityIds: starredIds,\n        });\n        const visible = allMatching.agents.filter(record => matchesAuthorFilter(record, filter));\n        const total = visible.length;\n        const startIdx = effectivePerPage === 0 ? 0 : page * effectivePerPage;\n        const endIdx = effectivePerPage === 0 ? 0 : startIdx + effectivePerPage;\n        const sliced = effectivePerPage === 0 ? [] : visible.slice(startIdx, endIdx);","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/stored-agents.ts#L271-L307","documentation":"When listing with ?favoritedOnly=true, the handler additionally needs the 'favorites' domain store to resolve the caller's starred agent IDs; if storage.getStore('favorites') returns undefined it throws HTTP 500. Only triggered on the favorites-filtered list path, after agents store resolution succeeds.","triggerScenarios":"GET /stored/agents?favoritedOnly=true (or pinFavoritedFor set) where the favorites feature flag is enabled but the storage adapter lacks a favorites domain store; adapter older than the favorites domain.","commonSituations":"Upgraded server enables favorites by default but the storage backend/adapter predates the favorites domain; custom adapter implements agents but not favorites; favorites feature flag turned on in config without migrating storage schema.","solutions":["Upgrade the storage adapter to a version implementing the favorites domain store","Run the adapter's schema/migration step so the favorites table/domain exists","Use an official adapter that supports favorites (@mastra/pg, @mastra/libsql current versions)","Disable the favorites builder feature if the backend cannot support it"],"exampleFix":"// before\npnpm add @mastra/pg@1.2.0 // no favorites domain\n// after\npnpm add @mastra/pg@latest && pnpm mastra db migrate","handlingStrategy":"fallback","validationCode":"const fav = await mastra.getStorage()?.getStore('favorites');\nif (!fav) console.warn('favorites domain unavailable; favoritedOnly queries will fail');","typeGuard":"function supportsFavorites(s: { getStore(d: string): Promise<unknown> }): Promise<boolean> {\n  return s.getStore('favorites').then(Boolean);\n}","tryCatchPattern":"try {\n  return await get('/stored/agents?favoritedOnly=true');\n} catch (e) {\n  if ((e as any).status === 500 && /Favorites storage domain/.test((e as any).message)) {\n    // degrade gracefully: fetch unfiltered list instead\n    return get('/stored/agents');\n  }\n  throw e;\n}","preventionTips":["Upgrade storage adapters before enabling the favorites feature flag","Run adapter migrations so the favorites domain exists","Feature-detect favorites support before sending favoritedOnly queries","Gate favorites UI on a server capability check"],"tags":["http-500","storage","favorites"],"backgroundTag":"storage-domain-unavailable","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}