jackwener/OpenCLI · error · CommandExecutionError

Unexpected LinkedIn Learning probe

Error message

Unexpected LinkedIn Learning probe: ${JSON.stringify(result)}

What it means

If the probe result is none of the known kinds (auth/http/exception) but lacks ok:true, the command throws CommandExecutionError with the full JSON-serialized probe result. This is a defensive catch-all ensuring unexpected probe outputs are never silently ignored, and the serialized result aids debugging.

Solutions

  1. Inspect the JSON in the message to see exactly what the probe returned.
  2. Update/reinstall the CLI so probe script and command handler versions match.
  3. Fix the probe script so every exit path sets kind (auth/http/exception) or ok:true.
  4. Add the missing branch to the probe's try/catch classification.

Example fix

// before
return { detail: 'unknown' }; // -> 'Unexpected LinkedIn Learning probe'
// after
return { kind: 'exception', detail: 'unknown' };
Defensive patterns

Strategy: type-guard

Type guard

function isKnownProbeResult(r) {
  return r && (r.ok === true || ['auth','http','exception'].includes(r.kind));
}

Try / catch

try {
  const identity = await verifyLinkedinLearningIdentity(page);
} catch (e) {
  if (e.message.startsWith('Unexpected LinkedIn Learning probe:')) {
    const probe = JSON.parse(e.message.slice('Unexpected LinkedIn Learning probe:'.length));
    console.error('probe returned unknown shape:', probe); // then update CLI/probe
    throw e;
  }
  throw e;
}

Prevention

When it happens

Trigger: page.evaluate returns an object without kind set (or a new/unexpected kind) and without ok:true — e.g. the probe's success path was not reached but it also didn't classify the failure, or an older/newer probe script version returns a different schema.

Common situations: Mixed versions of the CLI and its probe scripts; probe returned { ok: false } explicitly from an unhandled branch; a refactor of the evaluate script dropped the kind tagging.

Related errors


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

Appendix: source

Thrown at clis/linkedin-learning/auth.js:45

      if (!mini || !mini.publicIdentifier) {
        return { kind: 'auth', detail: 'LinkedIn /voyager/api/me 200 but miniProfile missing' };
      }
      const firstName = (mini.firstName && (mini.firstName.text || mini.firstName)) || '';
      const lastName = (mini.lastName && (mini.lastName.text || mini.lastName)) || '';
      return {
        ok: true,
        public_id: String(mini.publicIdentifier),
        plain_id: String(d.plainId || ''),
        name: String((firstName + ' ' + lastName).trim()),
      };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (result?.kind === 'auth') throw new AuthRequiredError('linkedin.com', result.detail);
  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /voyager/api/me`);
  if (result?.kind === 'exception') throw new CommandExecutionError(`LinkedIn Learning whoami failed: ${result.detail}`);
  if (!result?.ok) throw new CommandExecutionError(`Unexpected LinkedIn Learning probe: ${JSON.stringify(result)}`);
  return { public_id: result.public_id, plain_id: result.plain_id, name: result.name };
}

registerSiteAuthCommands({
  site: 'linkedin-learning',
  domain: 'linkedin.com',
  loginUrl: 'https://www.linkedin.com/login?session_redirect=%2Flearning%2F',
  columns: ['public_id', 'plain_id', 'name'],
  quickCheck: hasLinkedinSessionCookie,
  verify: verifyLinkedinLearningIdentity,
  poll: async (page) => {
    if (!await hasLinkedinSessionCookie(page)) {
      throw new AuthRequiredError('linkedin.com', 'Waiting for LinkedIn li_at cookie');
    }
    return verifyLinkedinLearningIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)