{"record":{"id":"dfbd91b591d79c12","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-instagram-reel","errorCode":null,"errorMessage":"Browser session required for instagram reel","messagePattern":"Browser session required for instagram reel","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/instagram/reel.js","lineNumber":14,"sourceCode":"import * as fs from 'node:fs';\nimport * 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) {","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/reel.js#L1-L32","documentation":"requirePage asserts that a browser page object exists before any Instagram reel posting work begins. The CLI operates a real browser session; if the page handle is null/undefined there is no browser to drive, so it throws a CommandExecutionError immediately. This is a fail-fast guard, not a report of a failed operation.","triggerScenarios":"Calling the instagram reel command when the underlying browser page is null/undefined — e.g. browserPage failed to launch or return a page, or the reel flow was invoked without an active browser session.","commonSituations":"Browser (Chromium/Playwright bridge) failed to start, headless environment missing the browser binary, Browser Bridge not connected, or a code path passing the result of a failed page lookup straight into requirePage.","solutions":["Ensure the browser session is started/connected before running the reel command (verify browserPage launches a page successfully).","Check that the browser binary is installed and reachable in the environment.","If using Browser Bridge, confirm the bridge is running and paired before invoking the command.","Wrap browserPage creation so a null page is logged with launch diagnostics instead of silently propagated."],"exampleFix":"// before\nawait runReel(page); // page may be undefined\n// after\nconst page = await browserPage();\nif (!page) throw new Error('Browser did not start; check browser binary/bridge');\nawait runReel(page);","handlingStrategy":"type-guard","validationCode":"if (!page || typeof page.evaluate !== 'function') throw new Error('No browser page available; start the browser session first');","typeGuard":"function hasPage(page) { return !!page && typeof page.evaluate === 'function' && typeof page.wait === 'function'; }","tryCatchPattern":"try { await runReel(args); } catch (e) { if (e.message.includes('Browser session required')) { await restartBrowserSession(); return runReel(args); } throw e; }","preventionTips":["Start and verify the browser session before any reel command","Health-check the page handle (page.evaluate('1')) before use","Log browser launch failures instead of passing null through"],"tags":["browser-session","precondition","instagram"],"backgroundTag":"browser-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}