yikart/AiToEarn · error · AppException
ChannelPlatformMediaProcessingFailed
ChannelPlatformMediaProcessingFailed
Error message
ResponseCode.ChannelPlatformMediaProcessingFailed
What it means
When downloading media without a platform/endpoint context (`input` is null), MediaService enforces a max byte size. If the downloaded buffer exceeds maxBytes it throws AppException ChannelPlatformMediaProcessingFailed with reasonCode 'media_exceeds_max_bytes' instead of the platform-scoped ChannelPlatformException.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/media/media.service.ts:909
}
private isImageExtension(extension: string | undefined): boolean {
return ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'tiff'].includes(extension ?? '')
}
private async downloadBuffer(url: string, input?: MediaHttpInput, maxBytes?: number): Promise<Buffer> {
const response = await this.http.get<ArrayBuffer | Buffer>(url, {
responseType: 'arraybuffer',
maxContentLength: maxBytes ?? Infinity,
maxBodyLength: maxBytes ?? Infinity,
...(input ? { channelMedia: input } : {}),
})
const buffer = Buffer.isBuffer(response.data)
? response.data
: Buffer.from(response.data)
if (maxBytes && buffer.length > maxBytes) {
if (!input) {
throw new AppException(ResponseCode.ChannelPlatformMediaProcessingFailed, {
reasonCode: 'media_exceeds_max_bytes',
maxBytes,
sizeBytes: buffer.length,
})
}
throw new ChannelPlatformException({
code: ResponseCode.ChannelPlatformMediaProcessingFailed,
platform: input.platform,
category: PlatformErrorCategory.MediaProcessingFailed,
context: {
endpoint: input.endpoint,
taskId: input.taskId,
accountId: input.accountId,
platformWorkId: input.platformWorkId,
},
cause: {
type: PlatformErrorCauseType.Platform,
platformMessage: 'Media exceeds maximum byte size',View on GitHub (pinned to d3aa8bea5b)
Solutions
- Check the returned context: sizeBytes vs maxBytes; source smaller media or re-encode/compress before upload.
- Raise maxBytes in the call site if the destination platform actually allows larger files.
- Provide platform/endpoint context (`input`) so the more informative ChannelPlatformException with platform/category is thrown instead.
- Catch this code and surface a 'file too large' message with both sizes.
Example fix
// before
await media.download(url, { maxBytes: 8 * 1024 * 1024 })
// after
await media.download(url, { maxBytes: 512 * 1024 * 1024 }) // match platform limit Defensive patterns
Strategy: validation
Validate before calling
const head = await axios.head(mediaUrl)
const size = Number(head.headers['content-length'] ?? 0)
if (size > maxBytes) throw new Error(`Media ${size} bytes exceeds limit ${maxBytes}`) Try / catch
try {
await media.fetch(url, { maxBytes })
} catch (e) {
if (e.code === 'ChannelPlatformMediaProcessingFailed' && e.context?.reasonCode === 'media_exceeds_max_bytes') {
return { error: 'FILE_TOO_LARGE', maxBytes: e.context.maxBytes, sizeBytes: e.context.sizeBytes }
}
throw e
} Prevention
- Set maxBytes to match the destination platform's real upload limit
- HEAD-check content-length before downloading large media
- Compress/re-encode oversized media server-side before fetching
When it happens
Trigger: A media fetch/download produced a buffer larger than maxBytes while input was null (no platform context supplied), so the guard at the `if (!input)` branch fires.
Common situations: Downloading an oversized video/image from a URL with a size cap configured; user supplies a very large media file link; maxBytes configured conservatively (e.g. platform upload limits) and remote asset grew.
Related errors
- ChannelPlatformMediaProcessingFailed
- ChannelPlatformMediaProcessingFailed
- ResponseCode.AssetTooLarge
- InvalidUrl
- ChannelPlatformMediaUnsupported
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/a93c0cf5f850350c.
Report an issue: GitHub.