{"record":{"id":"f20ec28d13b1f94a","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-linkedin-learning-cou","errorCode":null,"errorMessage":"Browser session required for linkedin-learning course","messagePattern":"Browser session required for linkedin-learning course","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin-learning/course.js","lineNumber":71,"sourceCode":"        released,\n        url: `https://www.linkedin.com/learning/${slug}`,\n    };\n}\n\ncli({\n    site: 'linkedin-learning',\n    name: 'course',\n    access: 'read',\n    description: 'Get LinkedIn Learning course detail by slug or course URL',\n    domain: DOMAIN,\n    strategy: Strategy.COOKIE,\n    browser: true,\n    args: [\n        { name: 'slug', type: 'string', required: true, positional: true, help: 'Course slug (e.g. agentic-ai-build-your-first-agentic-ai-system) or full /learning/<slug> URL' },\n    ],\n    columns: ['title', 'slug', 'description', 'difficulty', 'duration_sec', 'videos_count', 'rating', 'rating_count', 'released', 'url'],\n    func: async (page, args) => {\n        if (!page) throw new CommandExecutionError('Browser session required for linkedin-learning course');\n        const slug = parseSlug(args.slug);\n\n        const url = `https://www.linkedin.com/learning-api/courses?q=slug&slug=${encodeURIComponent(slug)}`;\n        const result = await fetchLinkedInLearningApi(page, url);\n        if (!result?.json) {\n            throw new CommandExecutionError(`LinkedIn Learning courses lookup failed: ${result?.error ?? 'no payload'}`);\n        }\n        const elements = result.json?.elements;\n        if (!Array.isArray(elements)) {\n            throw new CommandExecutionError('LinkedIn Learning courses lookup returned malformed payload: missing elements array');\n        }\n        const el = elements[0];\n        if (!el) {\n            throw new EmptyResultError(`No LinkedIn Learning course found for slug \"${slug}\"`);\n        }\n        const row = parseCourse(el, slug);\n        if (!row) {\n            throw new CommandExecutionError('LinkedIn Learning courses lookup returned malformed course detail: missing title');","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin-learning/course.js#L53-L89","documentation":"The linkedin-learning course command is registered with browser: true and a COOKIE strategy: it requires an authenticated browser (Playwright) session to call LinkedIn's learning-api with the user's cookies. When the func is invoked with page === null — i.e. no browser session was created — this CommandExecutionError is thrown before any lookup happens.","triggerScenarios":"Invoking the course command through a path that does not provision a browser page (headless harness, direct func call with null page, browser launch disabled/failed) so func receives page = null.","commonSituations":"Running the CLI in an environment where the embedded browser cannot launch (missing Playwright browsers, CI sandbox); calling the registered func programmatically without going through the browser bootstrap; disabling the --browser flag.","solutions":["Run the command with the browser session enabled (default path) so a logged-in Playwright page is provided.","Ensure Playwright browsers are installed and launchable (e.g. npx playwright install) in the environment.","Log in to linkedin.com in the session so the cookie-based authentication can be used."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!browserPage) {\n  throw new Error('linkedin-learning course requires a browser session; launch one first');\n}","typeGuard":"function hasBrowserPage(p) { return p !== null && p !== undefined && typeof p.goto === 'function'; }","tryCatchPattern":"try {\n  await runCommand('linkedin-learning', 'course', [slug]);\n} catch (e) {\n  if (String(e.message).includes('Browser session required')) {\n    await launchBrowserAndLogin(); // then retry\n  } else throw e;\n}","preventionTips":["Always invoke the command through the CLI bootstrap that provisions the browser page.","Run `npx playwright install` in fresh environments (CI containers).","Keep the LinkedIn session logged in so cookie-based bootstrap succeeds."],"tags":["browser-session","prerequisite","linkedin-learning"],"backgroundTag":"missing-browser-session","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}