{"record":{"id":"25615f077e63d136","repo":"yikart/AiToEarn","slug":"platformnotsupported","errorCode":"PlatformNotSupported","errorMessage":"ResponseCode.PlatformNotSupported","messagePattern":"ResponseCode\\.PlatformNotSupported","errorType":"exception","errorClass":"AppException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/auth/auth.service.ts","lineNumber":874,"sourceCode":"      redirectUri: session.redirectUri,\n      emptyAccountHint: emptyAccountHint\n        ? {\n            title: emptyAccountHint.title[locale],\n            description: emptyAccountHint.description[locale],\n            action: emptyAccountHint.action\n              ? {\n                  label: emptyAccountHint.action.label[locale],\n                  url: emptyAccountHint.action.url,\n                }\n              : undefined,\n          }\n        : undefined,\n    }\n  }\n\n  private getBackendAuthIntegration(platform: AccountType) {\n    if (!this.registry.has(platform)) {\n      throw new AppException(ResponseCode.PlatformNotSupported, { platform })\n    }\n\n    if (this.relayClientService?.enabled) {\n      throw new RelayAuthException()\n    }\n\n    const integration = this.registry.get(platform)\n    if (integration.metadata.authType === AuthType.Plugin) {\n      throw new AppException(ResponseCode.PlatformNotSupported, { platform })\n    }\n    if (!integration.auth) {\n      throw new AppException(ResponseCode.PlatformNotSupported, { platform, capability: 'auth' })\n    }\n    return integration\n  }\n\n  async resolveGroupId(userId: string, groupId?: string): Promise<string> {\n    if (groupId) {","sourceCodeStart":856,"sourceCodeEnd":892,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/auth/auth.service.ts#L856-L892","documentation":"getBackendAuthIntegration throws PlatformNotSupported (AppException, ResponseCode.PlatformNotSupported, detail { platform }) when the channel registry has no integration registered for the requested AccountType. It guards the first step of backend-driven auth: if the platform is unknown to this build, no OAuth flow can be started. A second throw of the same code occurs when the integration exists but its authType is Plugin, meaning auth must be handled by a plugin, not the backend.","triggerScenarios":"Calling an auth start/refresh endpoint with a platform string not in the registry (typo, new platform not registered in the module, platform supported only in the other China/international edition); requesting auth for a Plugin-type integration that must go through the plugin flow.","commonSituations":"Clients hardcoding a platform name that was renamed or added in a newer backend version; enabling/disabling platform modules via config so the registry lacks the integration; sending 'douyin' vs a plugin-managed platform where OAuth is delegated to a plugin.","solutions":["Check the platform value against the supported AccountType enum / registered integrations and fix the client's platform string.","For Plugin-type platforms, use the plugin auth flow instead of the backend auth endpoints.","Ensure the integration module for the platform is imported/registered in the server build you are running.","Catch the exception and read the `platform` detail to return a user-facing 'platform not supported' message instead of a generic 500."],"exampleFix":"// before\nawait authService.startAuth('xiaohongshu', userId) // throws if not registered\n// after\nif (!authService.isPlatformSupported('xiaohongshu')) {\n  throw new AppException(ResponseCode.PlatformNotSupported, { platform: 'xiaohongshu' })\n}\nawait authService.startAuth('xiaohongshu', userId)","handlingStrategy":"validation","validationCode":"if (!registry.has(platform)) {\n  throw new AppException(ResponseCode.PlatformNotSupported, { platform })\n}","typeGuard":"function isSupportedPlatform(p: string): p is AccountType {\n  return Object.values(AccountType).includes(p as AccountType) && registry.has(p as AccountType)\n}","tryCatchPattern":"try {\n  await authService.startAuth(platform, userId)\n} catch (e) {\n  if (e instanceof AppException && e.code === ResponseCode.PlatformNotSupported) {\n    return res.status(400).json({ message: `Platform ${e.details?.platform} is not supported` })\n  }\n  throw e\n}","preventionTips":["Derive platform lists for clients from the backend registry, not hardcoded enums.","Keep client and backend AccountType versions in sync (shared package or contract test).","Route plugin-type platforms to the plugin flow in the client before calling backend auth.","Verify the integration module is registered in the deployed build."],"tags":["unsupported-platform","registry","channels","config"],"backgroundTag":"platform-not-supported","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}