{"record":{"id":"07ace01571596d12","repo":"linshenkx/prompt-optimizer","slug":"failed-to-update-favorite-errormessage","errorCode":null,"errorMessage":"Failed to update favorite: ${errorMessage}","messagePattern":"Failed to update favorite: (.+?)","errorType":"exception","errorClass":"FavoriteStorageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/favorite/manager.ts","lineNumber":467,"sourceCode":"          ? this.attachPromptAssetMetadata(nextFavoriteBase)\n          : nextFavoriteBase;\n        assertFavoriteFitsItemBudget(nextFavorite);\n\n        favoritesList[index] = nextFavorite;\n        assertFavoritesPayloadWithinBudget(favoritesList, {\n          warnOnSoftLimit: true,\n        });\n\n        return favoritesList;\n      });\n\n      await this.updateStats();\n    } catch (error) {\n      if (error instanceof FavoriteError) {\n        throw error;\n      }\n      const errorMessage = error instanceof Error ? error.message : String(error);\n      throw new FavoriteStorageError(`Failed to update favorite: ${errorMessage}`);\n    }\n  }\n\n  async setFavoritePromptAssetCurrentVersion(id: string, versionId: string): Promise<void> {\n    await this.ensureInitialized();\n\n    try {\n      await this.storageProvider.updateData(this.STORAGE_KEYS.FAVORITES, (favorites: FavoritePrompt[] | null) => {\n        const favoritesList = favorites || [];\n        const index = favoritesList.findIndex(f => f.id === id);\n        if (index === -1) {\n          throw new FavoriteNotFoundError(id);\n        }\n\n        const currentFavorite = favoritesList[index];\n        const metadata = currentFavorite.metadata && typeof currentFavorite.metadata === 'object'\n          ? { ...currentFavorite.metadata }\n          : {};","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/manager.ts#L449-L485","documentation":"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.","triggerScenarios":"storageProvider.updateData or updateStats throwing during updateFavorite: write permissions, quota, locked backing store, or data that fails storage schema validation.","commonSituations":"Read-only storage location, disk full, provider not initialized, or a custom provider rejecting the payload.","solutions":["Read the wrapped errorMessage to find the storage-layer root cause","Confirm the manager is initialized and the storage location is writable","Free space / fix permissions on the backing store","If updateStats is the culprit, verify stats storage key access"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await manager.updateFavorite(id, updates); }\ncatch (e) {\n  if (e instanceof FavoriteStorageError) { /* log e.message, surface write issue */ }\n  else throw e;\n}","preventionTips":["Verify storage writability at startup","Handle storage quota/permission errors before mutating favorites"],"tags":["storage","write-failure","wrapper-error"],"backgroundTag":"storage-write-failure","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}