yikart/AiToEarn · error · AppException
PlatformNotSupported
PlatformNotSupported
Error message
ResponseCode.PlatformNotSupported
What it means
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.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/auth/auth.service.ts:874
redirectUri: session.redirectUri,
emptyAccountHint: emptyAccountHint
? {
title: emptyAccountHint.title[locale],
description: emptyAccountHint.description[locale],
action: emptyAccountHint.action
? {
label: emptyAccountHint.action.label[locale],
url: emptyAccountHint.action.url,
}
: undefined,
}
: undefined,
}
}
private getBackendAuthIntegration(platform: AccountType) {
if (!this.registry.has(platform)) {
throw new AppException(ResponseCode.PlatformNotSupported, { platform })
}
if (this.relayClientService?.enabled) {
throw new RelayAuthException()
}
const integration = this.registry.get(platform)
if (integration.metadata.authType === AuthType.Plugin) {
throw new AppException(ResponseCode.PlatformNotSupported, { platform })
}
if (!integration.auth) {
throw new AppException(ResponseCode.PlatformNotSupported, { platform, capability: 'auth' })
}
return integration
}
async resolveGroupId(userId: string, groupId?: string): Promise<string> {
if (groupId) {View on GitHub (pinned to d3aa8bea5b)
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.
Example fix
// before
await authService.startAuth('xiaohongshu', userId) // throws if not registered
// after
if (!authService.isPlatformSupported('xiaohongshu')) {
throw new AppException(ResponseCode.PlatformNotSupported, { platform: 'xiaohongshu' })
}
await authService.startAuth('xiaohongshu', userId) Defensive patterns
Strategy: validation
Validate before calling
if (!registry.has(platform)) {
throw new AppException(ResponseCode.PlatformNotSupported, { platform })
} Type guard
function isSupportedPlatform(p: string): p is AccountType {
return Object.values(AccountType).includes(p as AccountType) && registry.has(p as AccountType)
} Try / catch
try {
await authService.startAuth(platform, userId)
} catch (e) {
if (e instanceof AppException && e.code === ResponseCode.PlatformNotSupported) {
return res.status(400).json({ message: `Platform ${e.details?.platform} is not supported` })
}
throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/25615f077e63d136.
Report an issue: GitHub.