{"record":{"id":"875ca2facb79389b","repo":"yikart/AiToEarn","slug":"platformnotsupported-875ca2","errorCode":"PlatformNotSupported","errorMessage":"PlatformNotSupported","messagePattern":"PlatformNotSupported","errorType":"error_code","errorClass":"AppException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/wechat/wechat.service.ts","lineNumber":274,"sourceCode":"  private officialAccessTokenCache: { token: string, expiresAt: number } | null = null\n  private channelsAccessTokenCache: { token: string, expiresAt: number } | null = null\n\n  constructor(private readonly cfg: WechatConfig) {\n    this.httpClient = axios.create({ timeout: 30000 })\n    this.httpClient.interceptors.response.use(\n      (response) => {\n        this.throwIfWeChatApiError(response)\n        return response\n      },\n      (error: AxiosError<WeChatApiErrorResponse>) => {\n        throw this.fromAxiosError(error)\n      },\n    )\n  }\n\n  private get officialConfig(): WechatOfficialConfig {\n    if (!isAvailablePlatformConfig(this.cfg.official)) {\n      throw new AppException(ResponseCode.PlatformNotSupported, { platform: AccountType.WeChatOfficial })\n    }\n    return this.cfg.official\n  }\n\n  private get channelsConfig(): WechatChannelsConfig {\n    if (!isAvailablePlatformConfig(this.cfg.channels)) {\n      throw new AppException(ResponseCode.PlatformNotSupported, { platform: AccountType.WeChatChannels })\n    }\n    return this.cfg.channels\n  }\n\n  // ── Official Account OAuth2 ──\n\n  generateOfficialAuthUrl(redirectUri: string, state: string, scope: string): string {\n    const params = new URLSearchParams({\n      appid: this.officialConfig.appId,\n      redirect_uri: redirectUri,\n      response_type: 'code',","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/wechat/wechat.service.ts#L256-L292","documentation":"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.","triggerScenarios":"Any Official Account operation (OAuth, token refresh, user info, uploadImage) while cfg.official is missing required fields (appId/secret) or explicitly disabled via configuration.","commonSituations":"Missing WECHAT_OFFICIAL_* env vars in a deployment, intentionally disabled platform in a self-hosted install, typo in config keys so isAvailablePlatformConfig fails.","solutions":["Set the WeChat Official Account env/config values (appId, appSecret) and restart the service","Verify isAvailablePlatformConfig passes for cfg.official (all required keys non-empty)","If the platform is intentionally disabled, remove flows that route Official Account traffic to this instance","Check deployment docs (DOCKER_DEPLOYMENT_*.md) for the exact required variables"],"exampleFix":"// .env before\n# WECHAT_OFFICIAL_APPID not set\n// .env after\nWECHAT_OFFICIAL_APPID=wx1234567890\nWECHAT_OFFICIAL_APPSECRET=your-secret","handlingStrategy":"validation","validationCode":"const officialReady = !!(process.env.WECHAT_OFFICIAL_APPID && process.env.WECHAT_OFFICIAL_APPSECRET)\nif (!officialReady) throw new Error('WeChat Official platform not configured on this deployment')","typeGuard":"function isOfficialConfigured(cfg: unknown): cfg is { official: { appId: string; appSecret: string } } {\n  const c = cfg as any\n  return !!c?.official?.appId && !!c?.official?.appSecret\n}","tryCatchPattern":"try {\n  await wechatService.getOfficialUserInfo(token, openId)\n} catch (e) {\n  if (e?.code === 'PlatformNotSupported') {\n    logger.error('WeChat Official not configured; skipping channel sync', { channelId })\n    return\n  }\n  throw e\n}","preventionTips":["Set WECHAT_OFFICIAL_* env vars in every deployment","Run a startup config availability check","Document required vars in deployment docs","Fail fast with a clear message when the platform is disabled"],"tags":["wechat","configuration","missing-env-var","platform-not-supported"],"backgroundTag":"missing-env-var","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}