jackwener/OpenCLI · error · CommandExecutionError

LinkedIn messengerMessages API returned no pages.

Error message

LinkedIn messengerMessages API returned no pages.

What it means

Thrown by parseThreadPages when the in-page fetch script returns no pages to parse. The discovery/validation stage produced URLs, but the replay fetch loop yielded an empty or missing pages array, so there is no payload to extract messages from. It separates 'nothing was fetched' from 'fetched payload was malformed'.

Source

Thrown at clis/linkedin/thread-snapshot.js:201

      throw new CommandExecutionError('LinkedIn messengerMessages discovery returned an invalid URL.');
    }
    let decoded = value;
    try { decoded = decodeURIComponent(value); } catch {}
    if (url.protocol !== 'https:'
      || url.hostname !== LINKEDIN_DOMAIN
      || url.pathname !== '/voyager/api/voyagerMessagingGraphQL/graphql'
      || !/^messengerMessages\.[a-f0-9]+$/i.test(url.searchParams.get('queryId') || '')
      || !threadId
      || !decoded.includes(threadId)) {
      throw new CommandExecutionError('LinkedIn messengerMessages discovery returned an unsafe or mismatched URL.');
    }
  }
  return apiUrls;
}

function parseThreadPages(pages) {
  if (!Array.isArray(pages) || pages.length === 0) {
    throw new CommandExecutionError('LinkedIn messengerMessages API returned no pages.');
  }

  const entities = new Map();
  const apiUrls = [];
  for (const page of pages) {
    if (!page || typeof page !== 'object' || Array.isArray(page) || typeof page.url !== 'string') {
      throw new CommandExecutionError('LinkedIn messengerMessages API returned a malformed page wrapper.');
    }
    const normalized = page.json;
    if (!normalized || typeof normalized !== 'object' || Array.isArray(normalized)) {
      throw new CommandExecutionError('LinkedIn messengerMessages API returned a malformed normalized payload.');
    }
    if (Array.isArray(normalized.errors) && normalized.errors.length > 0) {
      throw new CommandExecutionError('LinkedIn messengerMessages GraphQL returned errors.');
    }
    if (!Array.isArray(normalized.included)) {
      throw new CommandExecutionError('LinkedIn messengerMessages payload is missing the included entity array.');
    }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Check the returned object for authRequired or error fields first and surface those (re-authenticate or retry) instead of calling parseThreadPages.
  2. Re-run the command after confirming the LinkedIn session is alive (page not on a login/checkpoint URL).
  3. Ensure the caller only invokes parseThreadPages with the { pages } result of a successful fetch script run.

Example fix

// before
parseThreadPages(result);
// after
if (result.authRequired) throw new AuthRequiredError();
if (result.error) throw new CommandExecutionError(result.error);
parseThreadPages(result.pages);
Defensive patterns

Strategy: try-catch

Validate before calling

const result = await runFetchScript();
if (!result || !Array.isArray(result.pages) || result.pages.length === 0) {
  throw new Error('Fetch returned no pages: ' + (result && (result.error || result.authRequired)));
}

Type guard

function hasPages(r) {
  return Boolean(r) && typeof r === 'object'
    && Array.isArray(r.pages) && r.pages.length > 0;
}

Try / catch

try {
  const snapshot = await cli.linkedin.threadSnapshot({ url: threadUrl });
} catch (err) {
  if (err.message.includes('returned no pages')) {
    // re-authenticate if the session expired, then retry once
  } else throw err;
}

Prevention

When it happens

Trigger: buildFetchThreadPagesScript resolves with an object lacking a non-empty pages array — e.g. the script returned its top-level { authRequired } or { error } branch result instead of { pages }, or apiUrls was reduced to zero entries between validation and fetch.

Common situations: Session cookie expired mid-run so the fetch script bailed with 401/403 and returned an error object; a network failure produced { error } instead of { pages }; the caller passed the wrong result object into parseThreadPages after an unexpected browser-navigation reset.

Related errors


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