{"record":{"id":"7b02681078d3a178","repo":"yikart/AiToEarn","slug":"channelplatformmediaprocessingfailed-7b0268","errorCode":"ChannelPlatformMediaProcessingFailed","errorMessage":"ChannelPlatformMediaProcessingFailed","messagePattern":"ChannelPlatformMediaProcessingFailed","errorType":"error_code","errorClass":"InstagramPlatformException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/instagram/instagram-publish.provider.ts","lineNumber":436,"sourceCode":"    let lastStatus: Awaited<ReturnType<InstagramService['getMediaContainerStatus']>> | undefined\n\n    await poll(\n      async () => {\n        const status = await this.instagramService.getMediaContainerStatus(\n          accessToken,\n          containerId,\n        )\n        lastStatus = status\n\n        if (status.statusCode === InstagramMediaContainerStatusCode.Finished) {\n          return { done: true, data: true }\n        }\n\n        if (\n          status.statusCode === InstagramMediaContainerStatusCode.Error\n          || status.statusCode === InstagramMediaContainerStatusCode.Expired\n        ) {\n          throw new InstagramPlatformException({\n            code: ResponseCode.ChannelPlatformMediaProcessingFailed,\n            category: PlatformErrorCategory.MediaProcessingFailed,\n            context: {\n              endpoint: 'waitForContainerReady',\n              platformWorkId: containerId,\n              metadata: { statusCode: status.statusCode, status: status.status },\n            },\n            cause: {\n              type: PlatformErrorCauseType.Platform,\n              platformCode: status.statusCode,\n              platformMessage: status.status,\n              raw: status,\n            },\n          })\n        }\n\n        return { done: false }\n      },","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/instagram/instagram-publish.provider.ts#L418-L454","documentation":"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.","triggerScenarios":"waitForContainerReady (polling loop used by publishSingleImage, publishCarousel, publishVideo, publishStory) reads the container status and sees status.statusCode === Error or Expired.","commonSituations":"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.","solutions":["Check status.status in the error context for Instagram's error message","Re-encode video to meet Instagram specs (H.264, AAC, 3-60s reels limits) and re-upload","Ensure the media URL is publicly reachable and not expiring quickly","Recreate the container promptly and publish immediately instead of reusing old containers"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// validate video specs before container creation\nif (!['H.264','H264'].includes(video.codec) || video.durationSeconds > 60 || video.durationSeconds < 3) {\n  throw new Error('Video does not meet Instagram reels specs')\n}","typeGuard":"function isTerminalFailure(statusCode: string): boolean {\n  return statusCode === 'ERROR' || statusCode === 'EXPIRED'\n}","tryCatchPattern":"try {\n  await provider.publish(input)\n} catch (e) {\n  if (e.code === 'ChannelPlatformMediaProcessingFailed') {\n    const { statusCode, status } = e.context.metadata\n    logger.error('IG container failed', { statusCode, status })\n    // ERROR/EXPIRED containers are not retryable as-is: recreate container with fixed media\n    await recreateContainerAndRepublish(input)\n  } else throw e\n}","preventionTips":["Re-encode media to Instagram specs before upload","Keep media URLs long-lived and publicly reachable","Publish soon after container creation to avoid EXPIRED","Surface status.status from the error context to diagnose content rejections"],"tags":["instagram","media","processing","video"],"backgroundTag":"media-processing-failed","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}