gitroomhq/postiz-app · error · BadBody

X failed to process the uploaded video${(processing as any)?

Error message

X failed to process the uploaded video${(processing as any)?.error?.message ? `: ${(processing as any).error.message}` : ''}

What it means

Right after finalizing a chunked video upload, X's finalize response reports processing_info.state === 'failed'. This is an explicit, permanent rejection: the video will never process, so it throws BadBody with X's error message when available.

Source

Thrown at libraries/nestjs-libraries/src/integrations/social/x.provider.ts:565

          media: await this.mediaChunk(path, start, end, this.identifier),
        },
        { forceBodyMode: 'form-data' }
      );
    }

    setHeartbeatDetails(`x: upload finalize media=${mediaId}`);
    const finalize = await client.v2.post<{
      data: {
        id: string;
        processing_info?: { state: string; check_after_secs?: number };
      };
    }>(`media/upload/${mediaId}/finalize`);

    const processing = finalize.data.processing_info;

    // An explicit rejection right at finalize: the video will never process.
    if (processing?.state === 'failed') {
      throw new BadBody(
        this.identifier,
        JSON.stringify(processing),
        Buffer.from('{}'),
        `X failed to process the uploaded video${
          (processing as any)?.error?.message
            ? `: ${(processing as any).error.message}`
            : ''
        }`
      );
    }

    // Per the docs a missing processing_info means the media is ready to use;
    // anything else keeps transcoding asynchronously and must reach
    // `succeeded` before the media_id can be attached to a post.
    return {
      mediaId,
      processing: !!processing && processing.state !== 'succeeded',
    };

View on GitHub (pinned to 0f1647f749)

Solutions

  1. Re-encode the video to H.264 MP4 + AAC within X's duration/size limits and re-upload
  2. Check the JSON processing_info in the error body for X's specific error code
  3. Verify chunk sizes/offsets were exact if you control the upload loop
  4. Retry once — occasional transcoder glitches do happen
Defensive patterns

Strategy: try-catch

Validate before calling

// validate video before uploading to X
const okVideo = file.mimetype === 'video/mp4' && durationSec <= 140 && sizeMB <= 512;
if (!okVideo) { /* transcode or reject before upload */ }

Type guard

const isFailedProcessing = (p?: { state?: string }) => p?.state === 'failed';

Try / catch

catch (e) { if (e instanceof BadBody && e.message.includes('process the uploaded video')) { const info = JSON.parse(String(e.body)); /* read info.error, re-encode media, retry */ } throw e; }

Prevention

When it happens

Trigger: POST media/upload/{id}/finalize returns processing_info with state 'failed': unsupported video codec/container, media too long or too large, corrupted chunk data, or X's transcoder rejecting the file.

Common situations: Videos in exotic codecs (e.g. some .mov/hevc variants), exceeded X's duration/size limits, chunked upload where a chunk was corrupted in transit.

Related errors


AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27). Data as JSON: /api/errors/c6f67b5f6a9aa3a5. Report an issue: GitHub.