jackwener/OpenCLI · error · CommandExecutionError

Instagram private publish video upload failed for ${prepared

Error message

Instagram private publish video upload failed for ${prepared.asset.fileName}

What it means

For video assets, the rupload_igvideo (or story video rupload) response must have status 'ok'; otherwise this error is thrown at clis/instagram/_shared/private-publish.js:824. The upload reached Instagram but was rejected at the application level, after HTTP and JSON parsing succeeded.

Source

Thrown at clis/instagram/_shared/private-publish.js:824

            headers: buildRuploadHeaders(prepared.asset, uploadId, context),
            body: prepared.asset.bytes,
        });
        const json = await parseJsonResponse(response, 'upload');
        if (String(json?.status || '') !== 'ok') {
            throw new CommandExecutionError(`Instagram private publish upload failed for ${prepared.asset.fileName}`);
        }
        return;
    }
    const videoResponse = await fetchPrivateUploadWithRetry(fetcher, `https://i.instagram.com/rupload_igvideo/fb_uploader_${uploadId}`, {
        method: 'POST',
        headers: mode === 'story'
            ? buildStoryVideoRuploadHeaders(prepared.asset, uploadId, context)
            : buildVideoRuploadHeaders(prepared.asset, uploadId, context),
        body: prepared.asset.bytes,
    });
    const videoJson = await parseJsonResponse(videoResponse, 'video upload');
    if (String(videoJson?.status || '') !== 'ok') {
        throw new CommandExecutionError(`Instagram private publish video upload failed for ${prepared.asset.fileName}`);
    }
    const coverResponse = await fetchPrivateUploadWithRetry(fetcher, `https://i.instagram.com/rupload_igphoto/fb_uploader_${uploadId}`, {
        method: 'POST',
        headers: buildVideoCoverRuploadHeaders(prepared.asset, uploadId, context),
        body: prepared.asset.coverImage.bytes,
    });
    const coverJson = await parseJsonResponse(coverResponse, 'video cover upload');
    if (String(coverJson?.status || '') !== 'ok') {
        throw new CommandExecutionError(`Instagram private publish video cover upload failed for ${prepared.asset.fileName}`);
    }
}
async function publishSidecarWithRetry(input) {
    const waitMs = input.waitMs ?? sleep;
    const requestInit = {
        method: 'POST',
        headers: {
            ...buildPrivateApiHeaders(input.apiContext),
            'Content-Type': 'application/json',

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Log the videoJson response body to read Instagram's rejection reason
  2. Re-encode to H.264/AAC mp4 matching the metadata headers the library sends
  3. Ensure duration is within story limits (≤15s) or run on macOS so trimming applies
  4. Retry later if the body indicates throttling/rate limit

Example fix

// before
execSync(`ffmpeg -i input.webm -c copy story.mp4`); // codec copied, still VP9
// after
execSync(`ffmpeg -i input.webm -c:v libx264 -pix_fmt yuv420p -c:a aac story.mp4`);
Defensive patterns

Strategy: validation

Validate before calling

if (!/\.mp4$/i.test(videoPath)) throw new Error('re-encode to H.264/AAC mp4 before private publish');
// optionally check duration via ffprobe:
// execSync(`ffprobe -v error -show_entries format=duration -of csv ${videoPath}`)

Try / catch

try { await publish(input); }
catch (e) {
  if (/video upload failed for/.test(e.message)) {
    console.error('Re-encode with: ffmpeg -i in -c:v libx264 -pix_fmt yuv420p -c:a aac out.mp4');
  }
  throw e;
}

Prevention

When it happens

Trigger: POST to https://i.instagram.com/rupload_igvideo/fb_uploader_<uploadId> returns JSON whose status is not 'ok' — bad video codec/container, incorrect rupload headers (duration, byte count, entity id), file too long for a story, or throttling.

Common situations: Uploading non-H.264 videos (e.g. VP9/AV1 webm mislabeled as mp4); header metadata (durationMs, bytes) mismatching the actual bytes; story videos longer than 15 seconds that escaped trimming; account-level upload restrictions.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/be9c7bcda99a48ca. Report an issue: GitHub.