{"record":{"id":"262b7f6f66cd3732","repo":"linshenkx/prompt-optimizer","slug":"failed-to-add-tag-errormessage","errorCode":null,"errorMessage":"Failed to add tag: ${errorMessage}","messagePattern":"Failed to add tag: (.+?)","errorType":"exception","errorClass":"FavoriteStorageError","httpStatus":null,"severity":"error","filePath":"packages/core/src/services/favorite/manager.ts","lineNumber":962,"sourceCode":"        const newTag: FavoriteTag = {\n          tag: trimmedTag,\n          createdAt: now\n        };\n\n        added = true;\n        return [...tagsList, newTag];\n      });\n\n      // 仅在新增标签时更新统计信息\n      if (added) {\n        await this.updateStats();\n      }\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(\n        `Failed to add tag: ${errorMessage}`,\n        error instanceof Error ? error : undefined\n      );\n    }\n  }\n\n  async renameTag(oldTag: string, newTag: string): Promise<number> {\n    if (!oldTag || !newTag) {\n      throw new FavoriteValidationError('Tag name cannot be empty');\n    }\n\n    if (oldTag === newTag) {\n      return 0; // 无需操作\n    }\n\n    let affectedCount = 0;\n    let oldTagExistedInIndependentLib = false;\n","sourceCodeStart":944,"sourceCodeEnd":980,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/core/src/services/favorite/manager.ts#L944-L980","documentation":"FavoriteStorageError wrapper thrown by addTag when the tag-library update fails for a non-FavoriteError reason. The original error is preserved as cause.","triggerScenarios":"storageProvider.updateData(TAGS, ...) throwing quota/I/O/serialization errors while inserting a new tag.","commonSituations":"Storage quota exhausted from many tags; provider write failures; concurrent tag writes colliding.","solutions":["Read error.cause for the root failure","Free storage space / prune unused tags","Retry once for transient provider errors"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"const isFavoriteStorageError = (e: unknown): e is FavoriteStorageError => e instanceof FavoriteStorageError;","tryCatchPattern":"try { await manager.addTag(t); } catch (e) { if (isFavoriteStorageError(e) && isTransient(e.cause)) await manager.addTag(t); else throw e; }","preventionTips":["Prune unused tags to keep the tag library small","Retry transient storage failures once"],"tags":["storage","tags","write","favorites"],"backgroundTag":"storage-write-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}