{"record":{"id":"2bff0e2b0d29d7a6","repo":"yikart/AiToEarn","slug":"channelplatformmediaprocessingfailed-2bff0e","errorCode":"ChannelPlatformMediaProcessingFailed","errorMessage":"ChannelPlatformMediaProcessingFailed","messagePattern":"ChannelPlatformMediaProcessingFailed","errorType":"error_code","errorClass":"PinterestPlatformException","httpStatus":null,"severity":"error","filePath":"project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/pinterest/pinterest-publish.provider.ts","lineNumber":248,"sourceCode":"    await this.mediaService.withUploadSource({\n      platform: this.platform,\n      endpoint: 'uploadVideo.downloadMedia',\n      url: videoUrl,\n    }, async (source) => {\n      await this.pinterestService.uploadVideoMedia(upload, await source.blob(), source.filename)\n    })\n\n    let lastStatus: Awaited<ReturnType<PinterestService['getMediaStatus']>> | undefined\n\n    return await poll(\n      async () => {\n        const status = await this.pinterestService.getMediaStatus(accessToken, upload.media_id)\n        lastStatus = status\n        if (status.status === PinterestMediaStatusValue.Succeeded) {\n          return { done: true, data: upload.media_id }\n        }\n        if (status.status === PinterestMediaStatusValue.Failed) {\n          throw new PinterestPlatformException({\n            code: ResponseCode.ChannelPlatformMediaProcessingFailed,\n            category: PlatformErrorCategory.MediaProcessingFailed,\n            context: {\n              endpoint: 'uploadVideo',\n              metadata: { mediaId: upload.media_id, status: status.status },\n            },\n            cause: {\n              type: PlatformErrorCauseType.Platform,\n              platformCode: status.status,\n              raw: status,\n            },\n          })\n        }\n        return { done: false }\n      },\n      {\n        intervalMs: 5000,\n        maxPollingMs: 5 * 60 * 1000,","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/pinterest/pinterest-publish.provider.ts#L230-L266","documentation":"ChannelPlatformMediaProcessingFailed is raised when Pinterest reports that an uploaded video media asset ended in the Failed state during uploadVideo polling. The provider polls getMediaStatus until Succeeded; if Pinterest returns Failed it wraps it in a PinterestPlatformException with the MediaProcessingFailed category. The video cannot be used for pin creation.","triggerScenarios":"uploadVideo() polling loop observes status.status === PinterestMediaStatusValue.Failed for the media_id — Pinterest's transcode/processing rejected the asset (bad codec, corrupt file, exceeds size/duration limits).","commonSituations":"Uploading videos with unsupported codecs/containers (e.g. non-H.264), files exceeding Pinterest's limits, truncated uploads, or very long videos that fail transcoding server-side.","solutions":["Re-encode the video to Pinterest-supported specs (MP4, H.264/AAC) and retry","Check Pinterest media limits (aspect ratio, duration, file size) and trim/compress the file","Inspect the logged mediaId/status metadata, re-upload a fresh asset rather than reusing media_id","Verify the source file is not corrupted before upload"],"exampleFix":"// before\nawait uploadVideo(accessToken, corruptedClip) // polls -> Failed -> ChannelPlatformMediaProcessingFailed\n// after\nconst fixed = await transcodeToMp4H264(corruptedClip, { maxDurationSec: 900 })\nawait uploadVideo(accessToken, fixed)","handlingStrategy":"retry","validationCode":"const PINTEREST_MAX = { width: 1024, height: 1024, durationSec: 900, sizeMB: 2000 }\nfunction validatePinterestVideo(v: { codec: string; container: string; durationSec: number; sizeMB: number }): boolean {\n  return v.codec === 'h264' && v.container === 'mp4' && v.durationSec <= PINTEREST_MAX.durationSec && v.sizeMB <= PINTEREST_MAX.sizeMB\n}","typeGuard":"function isPinterestMediaStatusFailed(status: { status: string }): boolean {\n  return status.status === 'Failed'\n}","tryCatchPattern":"try {\n  const mediaId = await provider.uploadVideo(accessToken, file)\n} catch (e) {\n  if (e instanceof PinterestPlatformException && e.code === ResponseCode.ChannelPlatformMediaProcessingFailed) {\n    const fixed = await transcodeToMp4H264(file)\n    mediaId = await provider.uploadVideo(accessToken, fixed) // retry once with re-encoded asset\n  } else throw e\n}","preventionTips":["Pre-encode to MP4/H.264/AAC before uploading","Enforce Pinterest duration/aspect/size limits at ingest","Log mediaId + status metadata (already in context) to diagnose failures","Re-upload fresh assets instead of reusing a failed media_id"],"tags":["pinterest","media","video-processing","upload"],"backgroundTag":"media-processing-failed","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}