{"record":{"id":"27547e110c0fc949","repo":"linshenkx/prompt-optimizer","slug":"failed-to-delete-tag-errormessage","errorCode":null,"errorMessage":"Failed to delete tag: ${errorMessage}","messagePattern":"Failed to delete tag: (.+?)","errorType":"exception","errorClass":"FavoriteStorageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/favorite/manager.ts","lineNumber":1142,"sourceCode":"        const favoritesList = favorites || [];\n\n        favoritesList.forEach(favorite => {\n          const index = favorite.tags.indexOf(tag);\n          if (index !== -1) {\n            favorite.tags.splice(index, 1);\n            favorite.updatedAt = Date.now();\n            affectedCount++;\n          }\n        });\n\n        return favoritesList;\n      });\n\n      await this.updateStats();\n      return affectedCount;\n    } catch (error) {\n      const errorMessage = error instanceof Error ? error.message : String(error);\n      throw new FavoriteStorageError(`Failed to delete tag: ${errorMessage}`);\n    }\n  }\n\n  async reorderCategories(categoryIds: string[]): Promise<void> {\n    if (!categoryIds || categoryIds.length === 0) {\n      throw new FavoriteValidationError('Category ID list cannot be empty');\n    }\n\n    try {\n      await this.storageProvider.updateData(this.STORAGE_KEYS.CATEGORIES, (categories: FavoriteCategory[] | null) => {\n        const categoriesList = categories || [];\n\n        // 创建ID到分类的映射\n        const categoryMap = new Map<string, FavoriteCategory>();\n        categoriesList.forEach(cat => categoryMap.set(cat.id, cat));\n\n        // 按提供的ID顺序重新排序,并更新sortOrder\n        const reorderedCategories: FavoriteCategory[] = [];","sourceCodeStart":1124,"sourceCodeEnd":1160,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/manager.ts#L1124-L1160","documentation":"FavoriteStorageError thrown by deleteTag when any of the deletion writes (tag library removal, rewriting favorites to drop the tag) or updateStats fails with a non-FavoriteError.","triggerScenarios":"Storage write failures while rewriting favorites that referenced the deleted tag; quota exhaustion on large datasets.","commonSituations":"Deleting a heavily-used tag requiring many favorite rewrites; provider I/O errors; partial deletion leaving inconsistencies.","solutions":["Check the wrapped cause message","Verify favorites' tags arrays after failure and repair inconsistencies","Retry once storage space is available"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;","tryCatchPattern":"try { return await manager.deleteTag(tag); } catch (e) { if (isFavoriteStorageError(e)) { /* verify favorites no longer reference the tag inconsistently; repair */ } throw e; }","preventionTips":["Expect heavy rewrites when deleting popular tags — ensure quota headroom"],"tags":["storage","tags","delete","favorites"],"backgroundTag":"storage-write-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}