yikart/AiToEarn · error · AppException
ChannelPlatformMediaProcessingFailed
ChannelPlatformMediaProcessingFailed
Error message
ChannelPlatformMediaProcessingFailed
What it means
ChannelPlatformMediaProcessingFailed (field video_id) is thrown by DouyinService.uploadVideo when the Douyin video upload API responds without data.video.video_id. The upload request itself completed at HTTP level, but the platform did not return the identifier needed for subsequent createVideo/publish calls, so the service flags media processing as failed.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/douyin/douyin.service.ts:492
accessToken: string,
openId: string,
videoBuffer: Buffer,
filename: string,
): Promise<{ videoId: string }> {
const formData = new FormData()
formData.append('video', new Blob([new Uint8Array(videoBuffer)]), filename)
const response = await this.http.post<DouyinApiResponse<DouyinVideoUploadResponse>>(
'/api/douyin/v1/video/upload_video/',
formData,
{
params: { open_id: openId },
headers: { 'access-token': accessToken },
},
)
const videoId = response.data.data.video?.video_id
if (!videoId) {
throw new AppException(ResponseCode.ChannelPlatformMediaProcessingFailed, { platform: AccountType.Douyin, field: 'video_id', reasonCode: 'missing_platform_field' })
}
return { videoId }
}
async uploadImage(
accessToken: string,
openId: string,
imageBuffer: Buffer,
filename: string,
): Promise<{ imageId: string }> {
const formData = new FormData()
formData.append('image', new Blob([new Uint8Array(imageBuffer)]), filename)
const response = await this.http.post<DouyinApiResponse<{ image?: { image_id?: string } }>>(
'/api/douyin/v1/video/upload_image/',
formData,
{View on GitHub (pinned to d3aa8bea5b)
Solutions
- Check the upload response envelope for a platform error code (e.g. access_token invalid) and refresh the user access token if expired.
- Validate the video file against Douyin limits (size, duration, mp4/H.264) before uploading.
- Confirm the open_id matches the account bound to the accessToken and that publish scope was granted.
- Retry the upload; if it persists with a valid token, capture the raw response and contact Douyin platform support.
Example fix
// before
const { videoId } = await douyinService.uploadVideo(openId, token, badFile) // no video_id returned
// after
// validate file then upload
const ok = file.size <= 128 * 1024 * 1024 && file.mimetype === 'video/mp4'
if (!ok) throw new Error('file exceeds Douyin limits')
const { videoId } = await douyinService.uploadVideo(openId, freshToken, file) // returns video_id Defensive patterns
Strategy: validation
Validate before calling
function assertDouyinVideoFile(f: { size: number; mimetype: string }) {
const MAX = 128 * 1024 * 1024
if (f.size > MAX) throw new Error('video exceeds Douyin 128MB limit')
if (!['video/mp4'].includes(f.mimetype)) throw new Error('only mp4 supported')
} Type guard
const hasVideoId = (r: unknown): r is { data: { data: { video: { video_id: string } } } } =>
!!r && typeof r === 'object' && typeof (r as any).data?.data?.video?.video_id === 'string' Try / catch
try {
const { videoId } = await douyinService.uploadVideo(openId, accessToken, file)
} catch (err) {
if (err instanceof AppException && err.code === ResponseCode.ChannelPlatformMediaProcessingFailed && err.data?.field === 'video_id') {
// refresh user token / revalidate file, then retry once
} else throw err
} Prevention
- Check token validity and refresh before long upload batches
- Enforce Douyin file limits (size, duration, format) client-side before upload
- Confirm open_id and accessToken come from the same authorized account
- Retry transient failures with exponential backoff instead of failing the whole publish
When it happens
Trigger: Calling uploadVideo (e.g. via videoId()) with an open_id/accessToken pair where the multipart upload returns an error envelope: invalid or expired access token, open_id not belonging to the authorized user, file exceeding Douyin size/duration limits, or platform error response with no video object.
Common situations: Access token expired after the user deauthorized the app; uploading a video over Douyin's limits (e.g. >128MB or wrong codec); account not granted video publish scope; transient Douyin incident returning empty data.
Related errors
- ChannelPlatformApiFailed
- AiCallFailed
- Relay API error [${body.code}]: ${body.message}
- InvalidModel
- AiCallFailed
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/bb3ea30423647eb5.
Report an issue: GitHub.