{"record":{"id":"71e8512b0822aa9c","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-linkedin-learning-tre","errorCode":null,"errorMessage":"Browser session required for linkedin-learning trending","messagePattern":"Browser session required for linkedin-learning trending","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin-learning/trending.js","lineNumber":40,"sourceCode":"        viewers: card?.viewerCount ?? '',\n        url: slug ? `https://www.linkedin.com/learning/${slug}` : '',\n    };\n}\n\ncli({\n    site: 'linkedin-learning',\n    name: 'trending',\n    access: 'read',\n    description: 'Browse LinkedIn Learning recommended courses across personalized carousels',\n    domain: DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'limit', type: 'int', default: 10, help: `Maximum results to return (1-${MAX_LIMIT})` },\n    ],\n    columns: ['rank', 'group', 'type', 'title', 'difficulty', 'viewers', 'url'],\n    func: async (page, args) => {\n        if (!page) throw new CommandExecutionError('Browser session required for linkedin-learning trending');\n        const limit = parseLimit(args.limit);\n\n        const url = `https://www.linkedin.com/learning-api/feedRecommendationGroups?countPerCarousel=${MAX_PER_CAROUSEL}&q=learner`;\n        const result = await fetchLinkedInLearningApi(page, url);\n        if (!result?.json) {\n            throw new CommandExecutionError(`LinkedIn Learning feedRecommendationGroups failed: ${result?.error ?? 'no payload'}`);\n        }\n        const groups = result.json?.elements;\n        if (!Array.isArray(groups)) {\n            throw new CommandExecutionError('LinkedIn Learning feedRecommendationGroups returned malformed payload: missing elements array');\n        }\n        const rows = [];\n        const seen = new Set();\n        let rank = 1;\n        let sawCards = false;\n        for (const group of groups) {\n            const carousels = Array.isArray(group?.carousels) ? group.carousels : [];\n            for (const carousel of carousels) {","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin-learning/trending.js#L22-L58","documentation":"Thrown at the start of the trending command when the func is invoked without a live browser page. The trending command is declared with browser:true; the CLI passes the page handle only when a browser session is running, so a null page means the command was invoked outside a browser-enabled session.","triggerScenarios":"Running 'clio linkedin-learning trending' without an active browser session (the CLI did not launch/attach the shared browser), or calling the command's func programmatically with page=null.","commonSituations":"Forgetting to start/reuse the CLI's browser session before browser-only commands, running in an environment where browser launch failed silently, or unit tests invoking func directly with no page.","solutions":["Run the command through the CLI normally so a browser session is started (browser:true commands must run in a browser-enabled invocation).","Start the shared browser session (per CLI docs, e.g. a browser open/login command) before trending.","Check that browser launch is not failing (missing Chrome/Playwright deps) causing page to be null.","In tests, pass a stub page object rather than null."],"exampleFix":"// before\nclio linkedin-learning trending          # no browser session -> error\n// after\nclio browser open\nclio linkedin-learning trending","handlingStrategy":"validation","validationCode":"// guard before invoking browser-required commands\nif (!page || typeof page.goto !== 'function') {\n  throw new Error('Browser session required: run via a browser-enabled CLI session');\n}","typeGuard":"function hasLivePage(page) {\n  return !!page && typeof page.goto === 'function' && typeof page.evaluate === 'function';\n}","tryCatchPattern":"try {\n  const rows = await trending(page);\n} catch (e) {\n  if (e.message.includes('Browser session required')) {\n    page = await ensureBrowserSession(); // start/reuse the CLI's browser\n    return trending(page);\n  }\n  throw e;\n}","preventionTips":["Always run linkedin-learning trending inside a browser-enabled CLI session","Start the shared browser session before scripting multiple commands","Fail fast on null page handles in wrappers instead of passing them through","Ensure the browser backend (Chrome/Playwright) is installed so launch failures don't yield null pages"],"tags":["browser","session","cli","precondition"],"backgroundTag":"missing-browser-session","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}