{"record":{"id":"24977a809f13d1c6","repo":"jackwener/OpenCLI","slug":"instagram-story-currently-supports-a-single-media","errorCode":null,"errorMessage":"Instagram story currently supports a single media item.","messagePattern":"Instagram story currently supports a single media item\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/instagram/story.js","lineNumber":27,"sourceCode":"const SUPPORTED_STORY_VIDEO_EXTENSIONS = new Set(['.mp4']);\nfunction requirePage(page) {\n    if (!page)\n        throw new CommandExecutionError('Browser session required for instagram story');\n    return page;\n}\nfunction validateInstagramStoryArgs(kwargs) {\n    if (kwargs.media === undefined) {\n        throw new ArgumentError('Argument \"media\" is required.', 'Provide --media /path/to/file.jpg or --media /path/to/file.mp4');\n    }\n}\nfunction normalizeStoryMediaItem(kwargs) {\n    const raw = String(kwargs.media ?? '').trim();\n    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);","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/story.js#L9-L45","documentation":"An ArgumentError thrown by normalizeStoryMediaItem() when the --media value contains more than one comma-separated path. The story upload path currently supports exactly one image or one video per post, so multi-item input is rejected early with guidance to pass a single path.","triggerScenarios":"kwargs.media splits into 2+ non-empty parts, e.g. --media 'a.jpg,b.jpg' or a stray comma like 'photo.jpg,' followed by another value.","commonSituations":"Trying to post multiple stories in one command, globbing patterns expanding to several files, or copy-pasting a comma-separated list intended for another command.","solutions":["Pass exactly one file path: --media /path/to/photo.jpg","Call the story command once per media item","Expand globs yourself and iterate, invoking the command per file","Remove accidental trailing/extra commas from the value"],"exampleFix":"// before\nawait story({ media: 'a.jpg,b.jpg' });\n// after\nfor (const f of ['a.jpg', 'b.jpg']) {\n  await story({ media: f });\n}","handlingStrategy":"validation","validationCode":"const parts = String(kwargs?.media ?? '').split(',').map(s => s.trim()).filter(Boolean);\nif (parts.length > 1) throw new Error('Pass one media file per story command');","typeGuard":"function isSingleMedia(v) { return typeof v === 'string' && v.split(',').filter(s => s.trim()).length === 1; }","tryCatchPattern":"try {\n  await postStory({ media: files });\n} catch (e) {\n  if (/single media item/.test(e.message)) {\n    for (const f of files.split(',')) await postStory({ media: f.trim() });\n  } else throw e;\n}","preventionTips":["Post one story per command invocation","Beware glob expansion producing multiple paths; quote globs","Strip accidental commas from user input","Document the single-item constraint in your wrapper scripts"],"tags":["arguments","validation","instagram","media"],"backgroundTag":"invalid-argument-value","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}