yikart/AiToEarn · error · InstagramPlatformException

ChannelPlatformMediaProcessingFailed

ChannelPlatformMediaProcessingFailed

Error message

ChannelPlatformMediaProcessingFailed

What it means

An Instagram media container finished processing with an Error or Expired status instead of FINISHED. The media (image/video/story) can't be published from that container, so the provider throws ChannelPlatformMediaProcessingFailed.

Source

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

    let lastStatus: Awaited<ReturnType<InstagramService['getMediaContainerStatus']>> | undefined

    await poll(
      async () => {
        const status = await this.instagramService.getMediaContainerStatus(
          accessToken,
          containerId,
        )
        lastStatus = status

        if (status.statusCode === InstagramMediaContainerStatusCode.Finished) {
          return { done: true, data: true }
        }

        if (
          status.statusCode === InstagramMediaContainerStatusCode.Error
          || status.statusCode === InstagramMediaContainerStatusCode.Expired
        ) {
          throw new InstagramPlatformException({
            code: ResponseCode.ChannelPlatformMediaProcessingFailed,
            category: PlatformErrorCategory.MediaProcessingFailed,
            context: {
              endpoint: 'waitForContainerReady',
              platformWorkId: containerId,
              metadata: { statusCode: status.statusCode, status: status.status },
            },
            cause: {
              type: PlatformErrorCauseType.Platform,
              platformCode: status.statusCode,
              platformMessage: status.status,
              raw: status,
            },
          })
        }

        return { done: false }
      },

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Check status.status in the error context for Instagram's error message
  2. Re-encode video to meet Instagram specs (H.264, AAC, 3-60s reels limits) and re-upload
  3. Ensure the media URL is publicly reachable and not expiring quickly
  4. Recreate the container promptly and publish immediately instead of reusing old containers
Defensive patterns

Strategy: retry

Validate before calling

// validate video specs before container creation
if (!['H.264','H264'].includes(video.codec) || video.durationSeconds > 60 || video.durationSeconds < 3) {
  throw new Error('Video does not meet Instagram reels specs')
}

Type guard

function isTerminalFailure(statusCode: string): boolean {
  return statusCode === 'ERROR' || statusCode === 'EXPIRED'
}

Try / catch

try {
  await provider.publish(input)
} catch (e) {
  if (e.code === 'ChannelPlatformMediaProcessingFailed') {
    const { statusCode, status } = e.context.metadata
    logger.error('IG container failed', { statusCode, status })
    // ERROR/EXPIRED containers are not retryable as-is: recreate container with fixed media
    await recreateContainerAndRepublish(input)
  } else throw e
}

Prevention

When it happens

Trigger: waitForContainerReady (polling loop used by publishSingleImage, publishCarousel, publishVideo, publishStory) reads the container status and sees status.statusCode === Error or Expired.

Common situations: Video violates Instagram reels/IGTV specs (codec, aspect ratio, duration); media URL unreachable or expired before Instagram downloaded it; container was created long before publishing and expired; copyrighted/blocked content.

Related errors


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