{"record":{"id":"4c2fdb7e29aca9e2","repo":"linshenkx/prompt-optimizer","slug":"failed-to-set-favorite-prompt-asset-current-versio","errorCode":null,"errorMessage":"Failed to set favorite prompt asset current version: ${errorMessage}","messagePattern":"Failed to set favorite prompt asset current version: (.+?)","errorType":"exception","errorClass":"FavoriteStorageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/favorite/manager.ts","lineNumber":522,"sourceCode":"          },\n        };\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 set favorite prompt asset current version: ${errorMessage}`);\n    }\n  }\n\n  async deleteFavoritePromptAssetVersion(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":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/manager.ts#L504-L540","documentation":"Catch-all FavoriteStorageError from setFavoritePromptAssetCurrentVersion wrapping any unexpected non-FavoriteError failure during the transactional update or the subsequent stats update.","triggerScenarios":"storageProvider.updateData or updateStats throwing (write failure, permissions, quota, serialization) during a version switch.","commonSituations":"Backing store unwritable or locked; interrupted write leaving the store inconsistent; custom provider throwing raw errors.","solutions":["Check the appended errorMessage for the storage root cause","Verify writability and initialization of the storage provider","Retry after resolving transient storage contention"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await manager.setFavoritePromptAssetCurrentVersion(id, versionId); }\ncatch (e) {\n  if (e instanceof FavoriteStorageError) { /* surface storage failure */ }\n  else throw e;\n}","preventionTips":["Ensure storage is initialized and writable before version switches","Back up favorites storage before batch version operations"],"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"}