{"record":{"id":"6f5be1e40e551bfa","repo":"jackwener/OpenCLI","slug":"instagram-private-publish-only-supports-single-vid","errorCode":null,"errorMessage":"Instagram private publish only supports single-video uploads through instagram reel","messagePattern":"Instagram private publish only supports single-video uploads through instagram reel","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/_shared/private-publish.js","lineNumber":893,"sourceCode":"}\nexport async function publishMediaViaPrivateApi(input) {\n    const now = input.now ?? (() => Date.now());\n    const clientSidecarId = String(now());\n    const uploadIds = input.mediaItems.length > 1\n        ? input.mediaItems.map((_, index) => String(now() + index + 1))\n        : [String(now())];\n    const fetcher = input.fetcher ?? ((url, init) => instagramPrivateApiFetch(input.page, url, init));\n    const prepareMediaAsset = input.prepareMediaAsset ?? prepareInstagramMediaAsset;\n    const assets = await Promise.all(input.mediaItems.map((item) => prepareMediaAsset(item)));\n    try {\n        for (let index = 0; index < assets.length; index += 1) {\n            const asset = assets[index];\n            const uploadId = uploadIds[index];\n            await uploadPreparedMediaAsset(fetcher, asset, uploadId, input.apiContext);\n        }\n        if (uploadIds.length === 1) {\n            if (assets[0]?.type !== 'image') {\n                throw new CommandExecutionError('Instagram private publish only supports single-video uploads through instagram reel');\n            }\n            const response = await fetcher('https://www.instagram.com/api/v1/media/configure/', {\n                method: 'POST',\n                headers: {\n                    ...buildPrivateApiHeaders(input.apiContext),\n                    'Content-Type': 'application/x-www-form-urlencoded',\n                },\n                body: buildConfigureBody({\n                    uploadId: uploadIds[0],\n                    caption: input.caption,\n                    jazoest: input.jazoest,\n                }),\n            });\n            const json = await parseJsonResponse(response, 'configure');\n            return { code: json?.media?.code, uploadIds };\n        }\n        const result = await publishSidecarWithRetry({\n            fetcher,","sourceCodeStart":875,"sourceCodeEnd":911,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/_shared/private-publish.js#L875-L911","documentation":"publishMediaViaPrivateApi supports two paths: a single image goes through /media/configure/, and multiple items go through configure_sidecar. If exactly one item is uploaded but it is not an image (i.e. a single video), there is no supported configure path in the private publish flow (videos are published via the instagram reel command), so the library throws this guard error.","triggerScenarios":"Calling publishMediaViaPrivateApi (or publishImagesViaPrivateApi with a video path) with mediaItems containing exactly one item whose prepared asset type is not 'image' — a single video upload.","commonSituations":"Passing a video file to publishImagesViaPrivateApi by mistake; dynamically selected media that happens to be one video; expecting parity with the multi-video sidecar path.","solutions":["Use the instagram reel publish command for single-video posts instead of the private media publish path.","Add a pre-check before calling: if mediaItems.length === 1 and type !== 'image', route to the reel flow.","Group the single video with at least one other item to use the sidecar path (if a carousel is acceptable).","Convert the video to a still image (thumbnail) if an image post is acceptable."],"exampleFix":"// before\nawait publishMediaViaPrivateApi({ mediaItems: [{ type: 'video', filePath: 'clip.mp4' }], apiContext });\n// after\nif (mediaItems.length === 1 && mediaItems[0].type === 'video') {\n  await publishReel({ filePath: 'clip.mp4', apiContext }); // reel path\n} else {\n  await publishMediaViaPrivateApi({ mediaItems, apiContext });\n}","handlingStrategy":"validation","validationCode":"function assertPublishableMediaItems(mediaItems) {\n  if (mediaItems.length === 1 && mediaItems[0].type !== 'image') {\n    throw new Error('Single video: use the instagram reel publish path instead');\n  }\n}\nassertPublishableMediaItems(mediaItems);","typeGuard":"function isSingleImage(items) {\n  return items.length === 1 && items[0].type === 'image';\n}","tryCatchPattern":null,"preventionTips":["Route single-video posts to the reel publish flow before calling this API.","Validate media item types/count before invoking publishMediaViaPrivateApi.","For mixed carousels, confirm the sidecar path supports your combination.","Add a unit test covering each media-shape → publish-path mapping."],"tags":["instagram","validation","unsupported-media-type","video"],"backgroundTag":"unsupported-media-type","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}