{"record":{"id":"8766ccae902ce598","repo":"linshenkx/prompt-optimizer","slug":"failed-to-get-favorite-details-errormessage","errorCode":null,"errorMessage":"Failed to get favorite details: ${errorMessage}","messagePattern":"Failed to get favorite details: (.+?)","errorType":"exception","errorClass":"FavoriteStorageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/favorite/manager.ts","lineNumber":422,"sourceCode":"    }\n  }\n\n  async getFavorite(id: string): Promise<FavoritePrompt> {\n    try {\n      const favorites = await this.getFavorites();\n      const favorite = favorites.find(f => f.id === id);\n\n      if (!favorite) {\n        throw new FavoriteNotFoundError(id);\n      }\n\n      return favorite;\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 get favorite details: ${errorMessage}`);\n    }\n  }\n\n  async updateFavorite(id: string, updates: Partial<FavoritePrompt>): Promise<void> {\n    await this.ensureInitialized();\n\n    try {\n      if (Object.prototype.hasOwnProperty.call(updates, 'metadata')) {\n        assertFavoriteMetadataHasNoInlineImages(updates.metadata);\n      }\n\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","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/manager.ts#L404-L440","documentation":"Generic FavoriteStorageError wrapping any unexpected failure that escapes getFavorite's normal flow, most commonly an underlying storage provider error (read failure, corrupted data, serialization issue). The original message is appended for diagnostics.","triggerScenarios":"getFavorites() or the storage provider read fails inside getFavorite with a non-FavoriteError exception: I/O error, quota, corrupted JSON, or an uninitialized provider.","commonSituations":"Backing store temporarily unavailable (locked file, permissions), corrupted favorites payload after an interrupted write, or a custom storage provider that throws raw errors.","solutions":["Inspect the appended errorMessage to identify the storage-layer cause","Verify storage initialization (ensure manager.initialize() completed) before calling getFavorite","Repair or reset the corrupted storage data if the message mentions parse/serialization errors","If transient (file lock, network), retry after the underlying issue clears"],"exampleFix":"// before\ntry { await manager.getFavorite(id); } catch (e) { /* unknown */ }\n// after\ntry { await manager.getFavorite(id); }\ncatch (e) {\n  if (e instanceof FavoriteStorageError) console.error('storage issue:', e.message);\n  throw e;\n}","handlingStrategy":"retry","validationCode":"await manager.getFavorites(); // smoke-test the storage read path first","typeGuard":null,"tryCatchPattern":"try { await manager.getFavorite(id); }\ncatch (e) {\n  if (e instanceof FavoriteStorageError) { /* inspect e.message, retry or surface */ }\n  else throw e;\n}","preventionTips":["Initialize the manager before any read","Keep storage location writable and backed up to recover from corruption"],"tags":["storage","io","wrapper-error"],"backgroundTag":"storage-read-failure","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}