{"record":{"id":"e7d4de48762021ea","repo":"jackwener/OpenCLI","slug":"video-path-cannot-be-empty","errorCode":null,"errorMessage":"Video path cannot be empty","messagePattern":"Video path cannot be empty","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/instagram/reel.js","lineNumber":20,"sourceCode":"import * as os from 'node:os';\nimport * as path from 'node:path';\nimport { Page as BrowserPage } from '@jackwener/opencli/browser/page';\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { ArgumentError, AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';\nimport { buildClickActionJs, buildEnsureComposerOpenJs, buildInspectUploadStageJs, } from './post.js';\nimport { resolveCurrentUserId, resolveInstagramRuntimeInfo } from './_shared/runtime-info.js';\nimport { INSTAGRAM_HOME_URL, gotoInstagramHome } from './_shared/navigation.js';\nconst SUPPORTED_VIDEO_EXTENSIONS = new Set(['.mp4']);\nconst INSTAGRAM_REEL_TIMEOUT_SECONDS = 600;\nfunction requirePage(page) {\n    if (!page)\n        throw new CommandExecutionError('Browser session required for instagram reel');\n    return page;\n}\nfunction validateVideoPath(input) {\n    const resolved = path.resolve(String(input || '').trim());\n    if (!resolved) {\n        throw new ArgumentError('Video path cannot be empty');\n    }\n    if (!fs.existsSync(resolved)) {\n        throw new ArgumentError(`Video file not found: ${resolved}`);\n    }\n    const ext = path.extname(resolved).toLowerCase();\n    if (!SUPPORTED_VIDEO_EXTENSIONS.has(ext)) {\n        throw new ArgumentError(`Unsupported video format: ${ext}`, 'Supported formats: .mp4');\n    }\n    return resolved;\n}\nfunction validateInstagramReelArgs(kwargs) {\n    if (kwargs.video === undefined) {\n        throw new ArgumentError('Argument \"video\" is required.', 'Provide --video /path/to/file.mp4');\n    }\n}\nfunction buildInstagramReelSuccessResult(url) {\n    return [{\n            status: '✅ Posted',","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/reel.js#L2-L38","documentation":"validateVideoPath resolves the user-supplied video argument; if the trimmed string produces an empty path it throws ArgumentError. The library requires an explicit video file to upload as a reel. It guards against empty, whitespace-only, or missing --video input.","triggerScenarios":"Invoking the reel command with no --video flag, an empty string, or a value consisting only of whitespace.","commonSituations":"Script/CI invocation where the video variable is unset or empty, quoting mistakes that drop the argument, or forgetting the flag entirely.","solutions":["Pass a valid path: instagram reel --video /path/to/file.mp4.","Check the variable feeding --video is set and non-empty in your script/CI.","Quote the path so shell parsing doesn't swallow it."],"exampleFix":"// before\nconst video = process.env.VIDEO || '';\nawait reel({ video });\n// after\nconst video = process.env.VIDEO;\nif (!video) throw new Error('VIDEO env var must point to an .mp4 file');\nawait reel({ video });","handlingStrategy":"validation","validationCode":"const video = (args.video || '').trim();\nif (!video) throw new Error('--video is required: provide /path/to/file.mp4');","typeGuard":"function hasVideoArg(kwargs) { return kwargs != null && typeof kwargs.video === 'string' && kwargs.video.trim().length > 0; }","tryCatchPattern":"try { await reel(args); } catch (e) { if (e.message === 'Video path cannot be empty') { console.error('Usage: --video /path/to/file.mp4'); process.exitCode = 2; return; } throw e; }","preventionTips":["Always pass --video explicitly; never rely on possibly-empty env vars","Validate CLI args at script start","Quote path arguments in shell scripts"],"tags":["argument-validation","missing-argument","instagram"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}