{"record":{"id":"be9c7bcda99a48ca","repo":"jackwener/OpenCLI","slug":"instagram-private-publish-video-upload-failed-for","errorCode":null,"errorMessage":"Instagram private publish video upload failed for ${prepared.asset.fileName}","messagePattern":"Instagram private publish video upload failed for (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/private-publish.js","lineNumber":824,"sourceCode":"            headers: buildRuploadHeaders(prepared.asset, uploadId, context),\n            body: prepared.asset.bytes,\n        });\n        const json = await parseJsonResponse(response, 'upload');\n        if (String(json?.status || '') !== 'ok') {\n            throw new CommandExecutionError(`Instagram private publish upload failed for ${prepared.asset.fileName}`);\n        }\n        return;\n    }\n    const videoResponse = await fetchPrivateUploadWithRetry(fetcher, `https://i.instagram.com/rupload_igvideo/fb_uploader_${uploadId}`, {\n        method: 'POST',\n        headers: mode === 'story'\n            ? buildStoryVideoRuploadHeaders(prepared.asset, uploadId, context)\n            : buildVideoRuploadHeaders(prepared.asset, uploadId, context),\n        body: prepared.asset.bytes,\n    });\n    const videoJson = await parseJsonResponse(videoResponse, 'video upload');\n    if (String(videoJson?.status || '') !== 'ok') {\n        throw new CommandExecutionError(`Instagram private publish video upload failed for ${prepared.asset.fileName}`);\n    }\n    const coverResponse = await fetchPrivateUploadWithRetry(fetcher, `https://i.instagram.com/rupload_igphoto/fb_uploader_${uploadId}`, {\n        method: 'POST',\n        headers: buildVideoCoverRuploadHeaders(prepared.asset, uploadId, context),\n        body: prepared.asset.coverImage.bytes,\n    });\n    const coverJson = await parseJsonResponse(coverResponse, 'video cover upload');\n    if (String(coverJson?.status || '') !== 'ok') {\n        throw new CommandExecutionError(`Instagram private publish video cover upload failed for ${prepared.asset.fileName}`);\n    }\n}\nasync function publishSidecarWithRetry(input) {\n    const waitMs = input.waitMs ?? sleep;\n    const requestInit = {\n        method: 'POST',\n        headers: {\n            ...buildPrivateApiHeaders(input.apiContext),\n            'Content-Type': 'application/json',","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/private-publish.js#L806-L842","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Log the videoJson response body to read Instagram's rejection reason","Re-encode to H.264/AAC mp4 matching the metadata headers the library sends","Ensure duration is within story limits (≤15s) or run on macOS so trimming applies","Retry later if the body indicates throttling/rate limit"],"exampleFix":"// before\nexecSync(`ffmpeg -i input.webm -c copy story.mp4`); // codec copied, still VP9\n// after\nexecSync(`ffmpeg -i input.webm -c:v libx264 -pix_fmt yuv420p -c:a aac story.mp4`);","handlingStrategy":"validation","validationCode":"if (!/\\.mp4$/i.test(videoPath)) throw new Error('re-encode to H.264/AAC mp4 before private publish');\n// optionally check duration via ffprobe:\n// execSync(`ffprobe -v error -show_entries format=duration -of csv ${videoPath}`)","typeGuard":null,"tryCatchPattern":"try { await publish(input); }\ncatch (e) {\n  if (/video upload failed for/.test(e.message)) {\n    console.error('Re-encode with: ffmpeg -i in -c:v libx264 -pix_fmt yuv420p -c:a aac out.mp4');\n  }\n  throw e;\n}","preventionTips":["Always publish H.264/AAC mp4 files (yuv420p pixel format)","Keep story videos under 15 seconds","Make sure file size/duration metadata matches what the rupload headers declare","Retry after backoff if the rejection is throttle-related"],"tags":["instagram-api","video-upload","codec","media"],"backgroundTag":"upload-rejected","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}