{"record":{"id":"770023b85877c720","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-twitter-quote","errorCode":null,"errorMessage":"Browser session required for twitter quote","messagePattern":"Browser session required for twitter quote","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/twitter/quote.js","lineNumber":125,"sourceCode":"\ncli({\n    site: 'twitter',\n    name: 'quote',\n    access: 'write',\n    description: 'Quote-tweet a specific tweet with your own text, optionally with a local or remote image',\n    domain: 'x.com',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'url', type: 'string', required: true, positional: true, help: 'The URL of the tweet to quote' },\n        { name: 'text', type: 'string', required: true, positional: true, help: 'The text content of your quote' },\n        { name: 'image', help: 'Optional local image path to attach to the quote tweet' },\n        { name: 'image-url', help: 'Optional remote image URL to download and attach to the quote tweet' },\n    ],\n    columns: ['status', 'message', 'text'],\n    func: async (page, kwargs) => {\n        if (!page)\n            throw new CommandExecutionError('Browser session required for twitter quote');\n        if (kwargs.image && kwargs['image-url']) {\n            throw new CommandExecutionError('Use either --image or --image-url, not both.');\n        }\n\n        // Validate URL (typed ArgumentError on malformed/off-domain inputs)\n        // before any browser interaction or remote image download.\n        const target = parseTweetUrl(kwargs.url);\n\n        let localImagePath;\n        let cleanupDir;\n        try {\n            if (kwargs.image) {\n                localImagePath = resolveImagePath(kwargs.image);\n            } else if (kwargs['image-url']) {\n                const downloaded = await downloadRemoteImage(kwargs['image-url']);\n                localImagePath = downloaded.absPath;\n                cleanupDir = downloaded.cleanupDir;\n            }","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/twitter/quote.js#L107-L143","documentation":"CommandExecutionError thrown at the top of the twitter quote command when the `page` argument is falsy — the command requires an active browser session but none was provided or the browser session was not started. All twitter commands of this style are browser-driven and cannot run without a live page.","triggerScenarios":"Calling the 'twitter quote' command without first launching/connecting the browser so func receives page === undefined/null.","commonSituations":"Forgetting to open the browser session before running the command; session crashed or was closed mid-run; running in a headless pipeline where the browser bootstrap step was skipped or failed; invoking the command programmatically without the page argument.","solutions":["Start the browser session (e.g. run the browser open/start command) before invoking twitter quote","Check that the previous step did not close the browser; keep the session alive across commands","Guard programmatically: verify the page/session exists before calling the command","Catch CommandExecutionError with the 'Browser session required' message and auto-start the browser then retry once"],"exampleFix":"// before\nawait cli.run('twitter quote', kwargs); // no browser open\n// after\nawait cli.run('browser open'); // ensure session\nawait cli.run('twitter quote', kwargs);","handlingStrategy":"validation","validationCode":"if (!browserSession || !browserSession.page) {\n  await cli.run('browser open');\n}","typeGuard":"function hasLivePage(page) {\n  return page != null && typeof page.evaluate === 'function' && typeof page.goto === 'function';\n}","tryCatchPattern":"try {\n  await cli.run('twitter quote', kwargs);\n} catch (e) {\n  if (e instanceof CommandExecutionError && /Browser session required/.test(e.message)) {\n    await cli.run('browser open');\n    return cli.run('twitter quote', kwargs);\n  }\n  throw e;\n}","preventionTips":["Always run the browser open/start command as a pipeline preflight step","Add a session health check before each twitter command in batch scripts","Avoid closing the browser between dependent commands","Watch for upstream steps that crash or close the session"],"tags":["browser-session","prerequisite","state"],"backgroundTag":"missing-browser-session","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}