{"record":{"id":"0ca6f0880259fd10","repo":"yikart/AiToEarn","slug":"platform","errorCode":null,"errorMessage":"不支持的平台: ${platform}","messagePattern":"不支持的平台: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-web/src/store/plugin/plats/manager.ts","lineNumber":51,"sourceCode":"  constructor() {\n    this.register(xhsInteraction)\n    this.register(douyinInteraction)\n  }\n\n  /**\n   * 注册平台\n   */\n  register(platform: IPlatformInteraction): void {\n    this.platforms.set(platform.platformType as SupportedPlatformType, platform)\n  }\n\n  /**\n   * 获取平台实例\n   */\n  get(platform: SupportedPlatformType): IPlatformInteraction {\n    const instance = this.platforms.get(platform)\n    if (!instance) {\n      throw new Error(`不支持的平台: ${platform}`)\n    }\n    return instance\n  }\n\n  /**\n   * 检查是否支持该平台\n   */\n  isSupported(platform: PlatType): platform is SupportedPlatformType {\n    return this.platforms.has(platform as SupportedPlatformType)\n  }\n\n  /**\n   * 获取所有支持的平台\n   */\n  getSupportedPlatforms(): SupportedPlatformType[] {\n    return Array.from(this.platforms.keys())\n  }\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-web/src/store/plugin/plats/manager.ts#L33-L69","documentation":"PluginPlatformManager.get(platform) looks up a registered IPlatformInteraction instance and throws `不支持的平台: ${platform}` when none is registered for that key. It is a registry-miss guard: only platforms registered in this.platforms at manager construction are usable for interactions like likeWork, commentWork, getHomeFeedList, etc.","triggerScenarios":"Calling manager.get() (directly or via likeWork/commentWork/favoriteWork/getHomeFeedList/getWorkDetail/instance) with a platform string not present in the registry — a typo, an UnsupportedPlatformType, or a platform adapter module that was never imported/registered.","commonSituations":"Config/data referencing a platform whose adapter wasn't added to the manager map; renames of SupportedPlatformType without updating the registry; dynamic platform values from backend that the frontend doesn't support.","solutions":["Verify the exact platform string against the SupportedPlatformType union and the keys registered in the manager's platforms map.","Register the missing platform adapter in the manager (e.g. this.platforms.set('douyin', new DouyinInteraction())).","Gate calls with manager.has(platform) (or equivalent isSupported check) before invoking actions.","If the platform value comes from backend data, whitelist-map it to supported types and skip unsupported entries gracefully."],"exampleFix":"// before\nconst plugin = pluginManager.get(platform) // throws for unknown platform\n\n// after\nif (!pluginManager.has(platform)) {\n  console.warn(`unsupported platform: ${platform}`)\n  return null\n}\nconst plugin = pluginManager.get(platform)","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['douyin', 'xhs']) // mirror manager registry keys\nif (!SUPPORTED.has(platform)) {\n  console.warn(`skip unsupported platform: ${platform}`)\n  return\n}\nconst plugin = pluginManager.get(platform)","typeGuard":"type SupportedPlatformType = 'douyin' | 'xhs'\nfunction isSupportedPlatform(p: string): p is SupportedPlatformType {\n  return p === 'douyin' || p === 'xhs'\n}","tryCatchPattern":"try {\n  const plugin = pluginManager.get(platform)\n  await plugin.likeWork(params)\n}\ncatch (e) {\n  if (e.message.startsWith('不支持的平台')) {\n    reportUnsupportedPlatform(platform)\n    return\n  }\n  throw e\n}","preventionTips":["Keep the SupportedPlatformType union and the manager registry keys in sync (single source of truth)","Always check manager.has(platform) (or equivalent) before get()","Sanitize platform values coming from backend/config against the whitelist","Register every new platform adapter in the manager at construction time","Add a unit test asserting every SupportedPlatformType resolves via get()"],"tags":["plugin","registry","unsupported-platform","configuration"],"backgroundTag":"unsupported-platform","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}