{"record":{"id":"cb4ea556c28f0411","repo":"jackwener/OpenCLI","slug":"unsupported-story-media-format-ext","errorCode":null,"errorMessage":"Unsupported story media format: ${ext}","messagePattern":"Unsupported story media format: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/instagram/story.js","lineNumber":40,"sourceCode":"    const parts = raw.split(',').map((part) => part.trim()).filter(Boolean);\n    if (parts.length === 0) {\n        throw new ArgumentError('Argument \"media\" is required.', 'Provide --media /path/to/file.jpg or --media /path/to/file.mp4');\n    }\n    if (parts.length > 1) {\n        throw new ArgumentError('Instagram story currently supports a single media item.', 'Provide one image or one video path with --media');\n    }\n    const resolved = path.resolve(parts[0]);\n    if (!fs.existsSync(resolved)) {\n        throw new ArgumentError(`Story media file not found: ${resolved}`);\n    }\n    const ext = path.extname(resolved).toLowerCase();\n    if (SUPPORTED_STORY_IMAGE_EXTENSIONS.has(ext)) {\n        return { type: 'image', filePath: resolved };\n    }\n    if (SUPPORTED_STORY_VIDEO_EXTENSIONS.has(ext)) {\n        return { type: 'video', filePath: resolved };\n    }\n    throw new ArgumentError(`Unsupported story media format: ${ext}`, 'Supported formats: images (.jpg, .jpeg, .png, .webp) and videos (.mp4)');\n}\nasync function resolveCurrentUsername(page, currentUserId = '') {\n    if (!currentUserId)\n        return '';\n    const runtimeInfo = await resolveInstagramRuntimeInfo(page);\n    const apiResult = await page.evaluate(`\n    (async () => {\n      const userId = ${JSON.stringify(currentUserId)};\n      const appId = ${JSON.stringify(runtimeInfo.appId || '')};\n      try {\n        const res = await fetch(\n          'https://www.instagram.com/api/v1/users/' + encodeURIComponent(userId) + '/info/',\n          {\n            credentials: 'include',\n            headers: appId ? { 'X-IG-App-ID': appId } : {},\n          },\n        );\n        if (!res.ok) return { ok: false };","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/story.js#L22-L58","documentation":"An ArgumentError thrown by normalizeStoryMediaItem() when the file extension is neither a supported story image (.jpg, .jpeg, .png, .webp) nor video (.mp4). Instagram's story API only accepts these formats, so unsupported types are rejected before upload.","triggerScenarios":"--media points to an existing file whose extension (lowercased) is not in SUPPORTED_STORY_IMAGE_EXTENSIONS or SUPPORTED_STORY_VIDEO_EXTENSIONS, e.g. .gif, .heic, .mov, .pdf, or no extension.","commonSituations":"iPhone HEIC photos, .MOV videos from iOS, GIFs, or files with missing/uppercase-handled extensions; also raw downloaded files not yet converted.","solutions":["Convert the file: images to .jpg/.png (e.g. `sips -s format jpeg` or ImageMagick `convert`), videos to .mp4 (e.g. `ffmpeg -i in.mov out.mp4`)","Rename the file so its extension matches its actual format (only if the format truly matches)","Pre-check the extension in your script before calling the command and convert as needed","Ensure the file has an extension at all"],"exampleFix":"// before\nawait story({ media: 'IMG_0001.HEIC' });\n// after\nexecSync('magick IMG_0001.HEIC IMG_0001.jpg');\nawait story({ media: 'IMG_0001.jpg' });","handlingStrategy":"validation","validationCode":"const ext = path.extname(mediaArg).toLowerCase();\nconst ok = ['.jpg', '.jpeg', '.png', '.webp', '.mp4'].includes(ext);\nif (!ok) throw new Error(`Convert ${ext} files to jpg/png/webp (image) or mp4 (video) first`);","typeGuard":"function isSupportedStoryMedia(p) {\n  const e = path.extname(p).toLowerCase();\n  return ['.jpg', '.jpeg', '.png', '.webp', '.mp4'].includes(e);\n}","tryCatchPattern":"try {\n  await postStory({ media: file });\n} catch (e) {\n  if (/Unsupported story media format/.test(e.message)) {\n    const out = file.replace(/\\\\.[^.]+$/, '.mp4');\n    execSync(`ffmpeg -i ${file} ${out}`);\n    await postStory({ media: out });\n  } else throw e;\n}","preventionTips":["Convert HEIC to JPG and MOV to MP4 before uploading","Normalize file extensions to lowercase","Pre-check extensions in wrapper scripts and auto-convert","Avoid uploading GIFs/PDFs/other unsupported formats"],"tags":["validation","media-format","file-type","instagram"],"backgroundTag":"unsupported-file-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}