yikart/AiToEarn · error · YouTubePlatformException

ChannelPlatformMediaUnsupported

ChannelPlatformMediaUnsupported

Error message

YouTube publish video missing

What it means

YouTubePublishProvider.publish() throws a YouTubePlatformException (code ChannelPlatformMediaUnsupported, category MediaProcessingFailed) when the resolved media for the publish task is not a video. YouTube publishing only supports video uploads, so a missing/non-video asset aborts the task with context { endpoint: 'publish', taskId, accountId }.

Source

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

      throw YouTubePlatformException.validation({
        code: ResponseCode.ChannelPlatformAccountMissing,
        category: PlatformErrorCategory.Auth,
        context: {
          endpoint: 'publish.channel',
          taskId: input.taskId,
          accountId: input.accountId,
        },
      })
    }

    const video = input.content.media[0]
    if (!video) {
      const exception = YouTubePlatformException.validation({
        code: ResponseCode.ChannelPlatformMediaUnsupported,
        category: PlatformErrorCategory.MediaProcessingFailed,
        context: { endpoint: 'publish', taskId: input.taskId, accountId: input.accountId },
      })
      this.logger.warn(exception, 'YouTube publish video missing')
      throw exception
    }

    const option: Partial<YoutubeOption> = input.option ?? {}
    const privacyStatus = option.privacyStatus ?? YoutubePrivacyStatus.Public
    await this.assertCategoryAssignable(input.credential.accessToken, option.categoryId, {
      endpoint: 'publish.category',
      taskId: input.taskId,
      accountId: input.accountId,
    })

    const result = await this.youtubeService.uploadVideo(input.credential.accessToken, {
      title: input.content.title ?? 'Untitled',
      description: stripTopicsFromBody(input.content.body),
      tags: parseTopicsFromBody(input.content.body),
      privacyStatus,
      videoUrl: video.url,
      categoryId: option.categoryId,

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Validate at task creation/scheduling time that YouTube-bound tasks include at least one video asset
  2. Check the task's media references still resolve (not deleted) and are typed as video before calling publish
  3. Fix client/UI to disallow YouTube as a target for non-video content

Example fix

// before
await youtubePublish.publish({ taskId, accountId, media: images, ... })
// after
const video = media.find((m) => m.type === MediaType.Video)
if (!video) {
  throw new AppException(ResponseCode.ChannelPlatformMediaUnsupported, { platform: 'youtube' })
}
await youtubePublish.publish({ taskId, accountId, media: [video], ... })
Defensive patterns

Strategy: validation

Validate before calling

const video = input.media?.find((m) => m.type === MediaType.Video)
if (!video) {
  throw new AppException(ResponseCode.ChannelPlatformMediaUnsupported, { platform: 'youtube', taskId: input.taskId })
}

Type guard

function hasVideoMedia(media: Array<{ type: MediaType }> | undefined): media is [Mediatype.Media, ...MediaType.Media[]] {
  return !!media && media.some((m) => m.type === MediaType.Video)
}

Try / catch

try {
  await youtubePublish.publish(input)
} catch (err) {
  if (err instanceof YouTubePlatformException && err.code === ResponseCode.ChannelPlatformMediaUnsupported) {
    return failPublish(input.taskId, 'YouTube requires a video asset')
  }
  throw err
}

Prevention

When it happens

Trigger: A publish task targeting YouTube whose media list has no video entry — the media was deleted before publishing, the wrong media type (image/text) was attached, or media resolution failed silently and returned undefined.

Common situations: Users select an image-only post and cross-post it to YouTube; media expired/cleaned up from storage between scheduling and publishing; a bug in media lookup returns the wrong asset type for the task.

Related errors


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