mastra-ai/mastra · critical · HTTPException
Favorites storage domain is not available
Error message
Favorites storage domain is not available
What it means
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.
Source
Thrown at packages/server/src/server/handlers/stored-agent-favorites.ts:25
import { assertReadAccess, getCallerAuthorId } from './authorship';
import { requireBuilderFeature } from './editor-builder';
import { handleError } from './error';
/**
* Resolves the storage and favorites domains, throwing 500 if unavailable.
*/
async function getFavoritesContext(mastra: Parameters<typeof requireBuilderFeature>[0]) {
const storage = mastra.getStorage();
if (!storage) {
throw new HTTPException(500, { message: 'Storage is not configured' });
}
const agentStore = await storage.getStore('agents');
if (!agentStore) {
throw new HTTPException(500, { message: 'Agents storage domain is not available' });
}
const favoritesStore = await storage.getStore('favorites');
if (!favoritesStore) {
throw new HTTPException(500, { message: 'Favorites storage domain is not available' });
}
return { agentStore, favoritesStore };
}
/**
* PUT /stored/agents/:storedAgentId/favorite
*/
export const FAVORITE_STORED_AGENT_ROUTE = createRoute({
method: 'PUT',
path: '/stored/agents/:storedAgentId/favorite',
responseType: 'json',
pathParamSchema: storedAgentIdPathParams,
responseSchema: favoriteToggleResponseSchema,
summary: 'Favorite a stored agent',
description: 'Marks the stored agent as favorited by the calling user. Idempotent.',
tags: ['Stored Agents'],
requiresAuth: true,
requiresPermission: 'stored-agents:read',View on GitHub (pinned to 75dd419e61)
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
Example fix
// before storage: oldAdapter v1 // lacks favorites store // after pnpm up @mastra/libsql@latest && run migrations
Defensive patterns
Strategy: validation
Validate before calling
const storage = mastra.getStorage();
if (storage && !(await storage.getStore('favorites'))) {
throw new Error('Storage adapter does not provide the favorites domain');
} Type guard
async function hasFavoritesDomain(storage: MastraStorage): Promise<boolean> {
return (await storage.getStore('favorites')) != null;
} Try / catch
try {
await favoritesApi.list();
} catch (e) {
if (e.status === 500 && /Favorites storage domain/.test(e.message)) {
runMigrationsAndAlert();
} else throw e;
} Prevention
- 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
When it happens
Trigger: Calling a favorites endpoint where storage and the agents store resolve, but storage.getStore('favorites') returns null (adapter lacking the favorites domain).
Common situations: Older storage adapter versions predating the favorites domain; adapters that implement agents but not favorites; schema not migrated after upgrading core/server packages.
Related errors
- Prompt blocks storage domain is not available
- Agents storage domain is not available
- Favorites storage domain is not available
- Storage is not configured
- Skills storage domain is not available
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/495f5c13dc42618d.
Report an issue: GitHub.