linshenkx/prompt-optimizer · error · FavoriteStorageError

Failed to update favorite: ${errorMessage}

Error message

Failed to update favorite: ${errorMessage}

What it means

Catch-all FavoriteStorageError from updateFavorite: any non-FavoriteError thrown while persisting the update (storage write failure, callback serialization error, stats update failure) is wrapped with its original message.

Source

Thrown at packages/core/src/services/favorite/manager.ts:467

          ? this.attachPromptAssetMetadata(nextFavoriteBase)
          : nextFavoriteBase;
        assertFavoriteFitsItemBudget(nextFavorite);

        favoritesList[index] = nextFavorite;
        assertFavoritesPayloadWithinBudget(favoritesList, {
          warnOnSoftLimit: true,
        });

        return favoritesList;
      });

      await this.updateStats();
    } catch (error) {
      if (error instanceof FavoriteError) {
        throw error;
      }
      const errorMessage = error instanceof Error ? error.message : String(error);
      throw new FavoriteStorageError(`Failed to update favorite: ${errorMessage}`);
    }
  }

  async setFavoritePromptAssetCurrentVersion(id: string, versionId: string): Promise<void> {
    await this.ensureInitialized();

    try {
      await this.storageProvider.updateData(this.STORAGE_KEYS.FAVORITES, (favorites: FavoritePrompt[] | null) => {
        const favoritesList = favorites || [];
        const index = favoritesList.findIndex(f => f.id === id);
        if (index === -1) {
          throw new FavoriteNotFoundError(id);
        }

        const currentFavorite = favoritesList[index];
        const metadata = currentFavorite.metadata && typeof currentFavorite.metadata === 'object'
          ? { ...currentFavorite.metadata }
          : {};

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Read the wrapped errorMessage to find the storage-layer root cause
  2. Confirm the manager is initialized and the storage location is writable
  3. Free space / fix permissions on the backing store
  4. If updateStats is the culprit, verify stats storage key access
Defensive patterns

Strategy: try-catch

Try / catch

try { await manager.updateFavorite(id, updates); }
catch (e) {
  if (e instanceof FavoriteStorageError) { /* log e.message, surface write issue */ }
  else throw e;
}

Prevention

When it happens

Trigger: storageProvider.updateData or updateStats throwing during updateFavorite: write permissions, quota, locked backing store, or data that fails storage schema validation.

Common situations: Read-only storage location, disk full, provider not initialized, or a custom provider rejecting the payload.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/07ace01571596d12. Report an issue: GitHub.