yikart/AiToEarn · error · InstagramPlatformException

ChannelPlatformApiFailed

ChannelPlatformApiFailed

Error message

ChannelPlatformApiFailed

What it means

An Instagram Graph API publish attempt hit the platform content publishing quota (or the API call failed in a way mapped to the Quota category). Before rethrowing, the provider tried to fetch the content publishing limit for extra context; the original error is wrapped in InstagramPlatformException with ChannelPlatformApiFailed.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/instagram/instagram-publish.provider.ts:126

      const rawError = err instanceof InstagramPlatformException
        && err.platformCause?.raw
        && typeof err.platformCause.raw === 'object'
        ? (err.platformCause.raw as { error?: { error_subcode?: number, fbtrace_id?: string } }).error
        : undefined

      if (!(err instanceof InstagramPlatformException) || rawError?.error_subcode !== 2207069) {
        throw err
      }

      let limit: Awaited<ReturnType<InstagramService['getContentPublishingLimit']>> | undefined
      try {
        limit = await this.instagramService.getContentPublishingLimit(accessToken, igUserId)
      }
      catch (limitErr) {
        this.logger.warn(limitErr, `Failed to fetch Instagram content publishing limit for ${igUserId}`)
      }

      throw new InstagramPlatformException({
        code: ResponseCode.ChannelPlatformApiFailed,
        category: PlatformErrorCategory.Quota,
        context: {
          ...err.context,
          taskId: input.taskId,
          accountId: input.accountId,
        },
        cause: {
          type: err.platformCause?.type ?? PlatformErrorCauseType.Platform,
          httpStatus: err.platformCause?.httpStatus,
          platformCode: err.platformCause?.platformCode,
          raw: err.platformCause?.raw,
          quota: {
            usage: limit?.quotaUsage,
            total: limit?.quotaTotal,
            durationSeconds: limit?.quotaDuration,
            fbtraceId: rawError.fbtrace_id,
          },

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Read err.context and the publishing-limit data to confirm quota exhaustion
  2. Back off and retry after the 24h window; spread scheduled tasks over time
  3. Wait between container creation and publish calls (respect per-call rate limits)
  4. If the account is a fresh/limited IG account, warm it up or publish fewer posts
Defensive patterns

Strategy: retry

Validate before calling

// check remaining quota before publishing
const limit = await instagramService.getContentPublishingLimit(accessToken, igUserId)
if (limit.quota_total <= limit.quota_used) {
  throw new Error('Instagram publishing quota exhausted; retry after window resets')
}

Try / catch

try {
  await provider.publish(input)
} catch (e) {
  if (e.code === 'ChannelPlatformApiFailed' && e.context?.category === 'quota') {
    await scheduleRetry(input.taskId, { delayMs: 60 * 60 * 1000, maxAttempts: 3 })
  } else throw e
}

Prevention

When it happens

Trigger: publish() catches an error from the Graph API publish/container call, and (when the error is quota-related) fetches getContentPublishingLimit then throws InstagramPlatformException(ChannelPlatformApiFailed, category Quota) enriched with taskId/accountId context.

Common situations: Account exceeded Instagram's ~25-posts-per-24h / 50-api-calls-per-24h publishing limit; burst publishing of many scheduled tasks at once; shared IP throttling; Graph API returned code 4, 9004, or rate-limit subcodes.

Related errors


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