{"record":{"id":"0d7c3ba5d492370e","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-chess-analyze","errorCode":null,"errorMessage":"Browser session required for chess analyze","messagePattern":"Browser session required for chess analyze","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/chess/analyze.js","lineNumber":24,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { CommandExecutionError } from '@jackwener/opencli/errors';\nimport { parseGameUrl } from './utils.js';\n\ncli({\n    site: 'chess',\n    name: 'analyze',\n    access: 'read',\n    description: 'Open a Chess.com game in the browser analysis board',\n    domain: 'www.chess.com',\n    strategy: Strategy.UI,\n    browser: true,\n    navigateBefore: false,\n    args: [\n        { name: 'game-url', type: 'string', required: true, positional: true, help: 'Full game URL, e.g. https://www.chess.com/game/live/168842570216' },\n    ],\n    columns: ['kind', 'game_id', 'analysis_url'],\n    func: async (page, kwargs) => {\n        if (!page) throw new CommandExecutionError('Browser session required for chess analyze');\n        const { kind, id } = parseGameUrl(kwargs['game-url']);\n        const analysisUrl = `https://www.chess.com/analysis/game/${kind}/${id}`;\n        try {\n            await page.goto(analysisUrl);\n            await page.wait(2);\n        } catch (error) {\n            throw new CommandExecutionError(`Failed to open Chess.com analysis board: ${error?.message || error}`);\n        }\n        return [{ kind, game_id: id, analysis_url: analysisUrl }];\n    },\n});\n","sourceCodeStart":6,"sourceCodeEnd":36,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/chess/analyze.js#L6-L36","documentation":"The chess analyze command operates on a live browser page (it navigates to Chess.com's analysis board), so it throws CommandExecutionError when invoked without an active browser session (page is null/falsy). This guards against running the command before a session is established.","triggerScenarios":"Running `chess analyze <game-url>` in an environment where no browser session exists — e.g. no prior session/login command opened a page, the session was closed, or the command was invoked headlessly without a page handle.","commonSituations":"Running the CLI fresh without starting the browser session; the browser crashed or was closed between commands; automation pipelines calling chess analyze out of order before session setup.","solutions":["Start/ensure a browser session before running chess analyze (the command that yields the `page`).","Reopen the browser session if it was closed or crashed, then re-run the command.","In automation, assert the page handle exists before invoking the command and fail early with a clearer message."],"exampleFix":"// before\nawait chessAnalyze({ gameUrl }); // page not open\n// after\nconst page = await openBrowserSession();\nawait chessAnalyze({ page, gameUrl });","handlingStrategy":"validation","validationCode":"if (!page) throw new Error('Open a browser session before running chess analyze');","typeGuard":"function hasPage(session) { return Boolean(session && typeof session.goto === 'function'); }","tryCatchPattern":"try {\n  await chessAnalyze({ page, gameUrl });\n} catch (err) {\n  if (String(err.message).includes('Browser session required')) {\n    page = await openBrowserSession();\n    await chessAnalyze({ page, gameUrl });\n  } else throw err;\n}","preventionTips":["Always open/verify the browser session before browser-dependent commands","Check session liveness between long-running steps","Order automation steps so session setup precedes page commands"],"tags":["browser-session","chess","cli"],"backgroundTag":"missing-session","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}