yikart/AiToEarn · error · Error
不支持的平台: ${platform}
Error message
不支持的平台: ${platform} What it means
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.
Source
Thrown at project/aitoearn-web/src/store/plugin/plats/manager.ts:51
constructor() {
this.register(xhsInteraction)
this.register(douyinInteraction)
}
/**
* 注册平台
*/
register(platform: IPlatformInteraction): void {
this.platforms.set(platform.platformType as SupportedPlatformType, platform)
}
/**
* 获取平台实例
*/
get(platform: SupportedPlatformType): IPlatformInteraction {
const instance = this.platforms.get(platform)
if (!instance) {
throw new Error(`不支持的平台: ${platform}`)
}
return instance
}
/**
* 检查是否支持该平台
*/
isSupported(platform: PlatType): platform is SupportedPlatformType {
return this.platforms.has(platform as SupportedPlatformType)
}
/**
* 获取所有支持的平台
*/
getSupportedPlatforms(): SupportedPlatformType[] {
return Array.from(this.platforms.keys())
}
View on GitHub (pinned to d3aa8bea5b)
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.
Example fix
// before
const plugin = pluginManager.get(platform) // throws for unknown platform
// after
if (!pluginManager.has(platform)) {
console.warn(`unsupported platform: ${platform}`)
return null
}
const plugin = pluginManager.get(platform) Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = new Set(['douyin', 'xhs']) // mirror manager registry keys
if (!SUPPORTED.has(platform)) {
console.warn(`skip unsupported platform: ${platform}`)
return
}
const plugin = pluginManager.get(platform) Type guard
type SupportedPlatformType = 'douyin' | 'xhs'
function isSupportedPlatform(p: string): p is SupportedPlatformType {
return p === 'douyin' || p === 'xhs'
} Try / catch
try {
const plugin = pluginManager.get(platform)
await plugin.likeWork(params)
}
catch (e) {
if (e.message.startsWith('不支持的平台')) {
reportUnsupportedPlatform(platform)
return
}
throw e
} Prevention
- 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()
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- PlatformNotSupported
- PlatformNotSupported
- InvalidModel
- InvalidModel
- image aspectRatio cannot be converted to a supported size
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/0ca6f0880259fd10.
Report an issue: GitHub.