jackwener/OpenCLI · error · CommandExecutionError

LinkedIn Learning courses lookup failed: ${result?.error ??

Error message

LinkedIn Learning courses lookup failed: ${result?.error ?? 'no payload'}

What it means

After navigating to https://www.linkedin.com/learning-api/courses?q=slug&slug=<slug> inside the browser session, fetchLinkedInLearningApi returned no JSON payload (result.json falsy). The library wraps the underlying cause (result.error, or 'no payload') in a CommandExecutionError. Typical causes are auth/redirect to login, LinkedIn challenge pages, network errors, or the API returning non-JSON HTML.

Source

Thrown at clis/linkedin-learning/course.js:77

    site: 'linkedin-learning',
    name: 'course',
    access: 'read',
    description: 'Get LinkedIn Learning course detail by slug or course URL',
    domain: DOMAIN,
    strategy: Strategy.COOKIE,
    browser: true,
    args: [
        { 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' },
    ],
    columns: ['title', 'slug', 'description', 'difficulty', 'duration_sec', 'videos_count', 'rating', 'rating_count', 'released', 'url'],
    func: async (page, args) => {
        if (!page) throw new CommandExecutionError('Browser session required for linkedin-learning course');
        const slug = parseSlug(args.slug);

        const url = `https://www.linkedin.com/learning-api/courses?q=slug&slug=${encodeURIComponent(slug)}`;
        const result = await fetchLinkedInLearningApi(page, url);
        if (!result?.json) {
            throw new CommandExecutionError(`LinkedIn Learning courses lookup failed: ${result?.error ?? 'no payload'}`);
        }
        const elements = result.json?.elements;
        if (!Array.isArray(elements)) {
            throw new CommandExecutionError('LinkedIn Learning courses lookup returned malformed payload: missing elements array');
        }
        const el = elements[0];
        if (!el) {
            throw new EmptyResultError(`No LinkedIn Learning course found for slug "${slug}"`);
        }
        const row = parseCourse(el, slug);
        if (!row) {
            throw new CommandExecutionError('LinkedIn Learning courses lookup returned malformed course detail: missing title');
        }
        return [row];
    },
});

export const __test__ = { parseSlug, parseCourse };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-authenticate: refresh the LinkedIn session cookies / log in again in the browser session and retry.
  2. Read the embedded cause (result.error) in the message and fix that specific issue (e.g. challenge -> solve the check, network -> retry).
  3. Retry after a delay — rate limiting and transient network failures are common causes of an empty payload.
  4. Verify the request works in a normal logged-in browser at the same learning-api URL to rule out an API-side change.
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check session health before the call:
const who = await fetchLinkedInLearningApi(page, 'https://www.linkedin.com/learning-api/me');
if (!who?.json) throw new Error('LinkedIn session invalid — re-login before course lookup');

Type guard

function hasPayload(result) { return result != null && typeof result === 'object' && result.json != null; }

Try / catch

try {
  await runCommand('linkedin-learning', 'course', [slug]);
} catch (e) {
  if (/courses lookup failed/.test(e.message)) {
    await refreshSessionOrBackoff(e.message); // includes embedded cause in message
  } else throw e;
}

Prevention

When it happens

Trigger: Calling linkedin-learning course with a page whose cookies are missing/expired, a logged-out session, a rate-limit or challenge response, or any fetch/navigation failure inside fetchLinkedInLearningApi so that result.json is undefined.

Common situations: Expired LinkedIn session cookies; logged-out or guest browser profile; LinkedIn serving the login wall or an anti-bot challenge; transient network/SSL failures; LinkedIn API shape or auth changes.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/30d1113089a17abd. Report an issue: GitHub.