yikart/AiToEarn · error · AppException

PlatformNotSupported

PlatformNotSupported

Error message

PlatformNotSupported

What it means

wechat.service officialConfig is a private getter that returns the WeChat Official Account config only when isAvailablePlatformConfig deems it usable. Otherwise AppException(ResponseCode.PlatformNotSupported, { platform: WeChatOfficial }) is thrown, meaning the platform is not configured/enabled in this deployment.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/wechat/wechat.service.ts:274

  private officialAccessTokenCache: { token: string, expiresAt: number } | null = null
  private channelsAccessTokenCache: { token: string, expiresAt: number } | null = null

  constructor(private readonly cfg: WechatConfig) {
    this.httpClient = axios.create({ timeout: 30000 })
    this.httpClient.interceptors.response.use(
      (response) => {
        this.throwIfWeChatApiError(response)
        return response
      },
      (error: AxiosError<WeChatApiErrorResponse>) => {
        throw this.fromAxiosError(error)
      },
    )
  }

  private get officialConfig(): WechatOfficialConfig {
    if (!isAvailablePlatformConfig(this.cfg.official)) {
      throw new AppException(ResponseCode.PlatformNotSupported, { platform: AccountType.WeChatOfficial })
    }
    return this.cfg.official
  }

  private get channelsConfig(): WechatChannelsConfig {
    if (!isAvailablePlatformConfig(this.cfg.channels)) {
      throw new AppException(ResponseCode.PlatformNotSupported, { platform: AccountType.WeChatChannels })
    }
    return this.cfg.channels
  }

  // ── Official Account OAuth2 ──

  generateOfficialAuthUrl(redirectUri: string, state: string, scope: string): string {
    const params = new URLSearchParams({
      appid: this.officialConfig.appId,
      redirect_uri: redirectUri,
      response_type: 'code',

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Set the WeChat Official Account env/config values (appId, appSecret) and restart the service
  2. Verify isAvailablePlatformConfig passes for cfg.official (all required keys non-empty)
  3. If the platform is intentionally disabled, remove flows that route Official Account traffic to this instance
  4. Check deployment docs (DOCKER_DEPLOYMENT_*.md) for the exact required variables

Example fix

// .env before
# WECHAT_OFFICIAL_APPID not set
// .env after
WECHAT_OFFICIAL_APPID=wx1234567890
WECHAT_OFFICIAL_APPSECRET=your-secret
Defensive patterns

Strategy: validation

Validate before calling

const officialReady = !!(process.env.WECHAT_OFFICIAL_APPID && process.env.WECHAT_OFFICIAL_APPSECRET)
if (!officialReady) throw new Error('WeChat Official platform not configured on this deployment')

Type guard

function isOfficialConfigured(cfg: unknown): cfg is { official: { appId: string; appSecret: string } } {
  const c = cfg as any
  return !!c?.official?.appId && !!c?.official?.appSecret
}

Try / catch

try {
  await wechatService.getOfficialUserInfo(token, openId)
} catch (e) {
  if (e?.code === 'PlatformNotSupported') {
    logger.error('WeChat Official not configured; skipping channel sync', { channelId })
    return
  }
  throw e
}

Prevention

When it happens

Trigger: Any Official Account operation (OAuth, token refresh, user info, uploadImage) while cfg.official is missing required fields (appId/secret) or explicitly disabled via configuration.

Common situations: Missing WECHAT_OFFICIAL_* env vars in a deployment, intentionally disabled platform in a self-hosted install, typo in config keys so isAvailablePlatformConfig fails.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/875ca2facb79389b. Report an issue: GitHub.