mastra-ai/mastra · critical · HTTPException

Favorites storage domain is not available

Error message

Favorites storage domain is not available

What it means

In the stored-skills list handler, when filtering by favorites (favoritedBy / favorite subject), it resolves the favorites store via storage.getStore('favorites'); if unavailable it throws HTTPException 500 'Favorites storage domain is not available'. This path only runs for favorites-filtered queries, so the error appears only when the request asks for skills the caller (or subject user) has favorited.

Source

Thrown at packages/server/src/server/handlers/stored-skills.ts:171

      const scope = await getStoredResourceScope(mastra, requestContext);
      const scopedMetadata = scopeStoredResourceMetadata(metadata, scope);

      const callerId = getCallerAuthorId(requestContext);
      const favoritesEnabled = await isBuilderFeatureEnabled(mastra, 'favorites');
      const honoredStarredOnly = favoritesEnabled && favoritedOnly === true;
      const favoriteSubjectId = pinFavoritedFor ?? callerId;

      // `?favoritedOnly=true` flow: fetch caller's favorited IDs, restrict the list
      // to that set, then post-filter by visibility and recompute total/pages.
      if (honoredStarredOnly) {
        const effectivePerPage: number = perPage ?? 100;
        if (!favoriteSubjectId) {
          // Caller cannot have favorited anything without an identity.
          return { skills: [], total: 0, page, perPage: effectivePerPage, hasMore: false };
        }
        const favoritesStore = await storage.getStore('favorites');
        if (!favoritesStore) {
          throw new HTTPException(500, { message: 'Favorites storage domain is not available' });
        }
        const starredIds = await favoritesStore.listFavoritedIds({ userId: favoriteSubjectId, entityType: 'skill' });
        if (starredIds.length === 0) {
          return { skills: [], total: 0, page, perPage: effectivePerPage, hasMore: false };
        }
        const allMatching = await skillStore.listResolved({
          perPage: false,
          orderBy,
          status,
          authorId: filter.kind === 'exact' ? filter.authorId : undefined,
          metadata: scopedMetadata,
          entityIds: starredIds,
        });
        const visible = allMatching.skills.filter(record => matchesAuthorFilter(record, filter));
        const total = visible.length;
        const startIdx = effectivePerPage === 0 ? 0 : page * effectivePerPage;
        const endIdx = effectivePerPage === 0 ? 0 : startIdx + effectivePerPage;
        const sliced = effectivePerPage === 0 ? [] : visible.slice(startIdx, endIdx);

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Switch to a storage adapter implementing the favorites domain (current @mastra/libsql/@mastra/pg)
  2. Apply the favorites schema/migrations on the target database
  3. Pin matching versions of @mastra/core and the storage package so domain registration works
  4. Guard the UI to disable the favorites filter until the backend supports it

Example fix

// before
storage: new MastraMemoryStorage(); // no favorites domain; favorites filter 500s

// after
storage: new PgStore({ connectionString: process.env.DATABASE_URL }); // favorites domain included
Defensive patterns

Strategy: fallback

Validate before calling

const storage = mastra.getStorage();
if (!storage || !(await storage.getStore('favorites'))) {
  // hide the favorites filter before issuing the query
  disableFavoritesFilter();
}

Try / catch

try {
  return await api.get('/stored/skills?favorited=true');
} catch (e) {
  if (isHttpError(e) && /Favorites storage domain/.test(e.message)) {
    return { skills: [], total: 0, page, perPage, hasMore: false }; // degrade
  }
  throw e;
}

Prevention

When it happens

Trigger: GET /stored/skills with a favorites filter (e.g. favorited=true / favoritedBy subject) when the storage adapter doesn't provide a 'favorites' store; note the handler earlier returns an empty page instead if the subject id can't be resolved, so reaching this error means a subject was identified but the store is missing.

Common situations: Adapter without the favorites domain (in-memory or legacy/custom store); favorites tables not migrated; only some environments' storage configured with the favorites domain so the UI favorites tab fails there.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/f1a188f3275b5265. Report an issue: GitHub.