jackwener/OpenCLI · warning · EmptyResultError

linkedin thread-snapshot

Error message

linkedin thread-snapshot

What it means

This is an EmptyResultError, not a CommandExecutionError: after successful parsing and deduplication, zero Message entities survived, so the thread has no snapshot-able messages. The library throws it to signal a legitimate empty result distinct from a malformed payload, letting callers handle 'nothing found' uniformly.

Source

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

    const senderUrn = normalizeWhitespace(entity['*sender'] || entity['*actor']);
    const sender = senderUrn ? entities.get(senderUrn) : null;
    const speaker = participantName(sender);
    if (!speaker) {
      throw new CommandExecutionError('LinkedIn messengerMessages payload contains a message with an unresolved sender.');
    }
    byMessageId.set(messageId, {
      messageUrn: messageId,
      speaker,
      text: messageText(entity),
      deliveredAt,
    });
  }

  const messages = Array.from(byMessageId.values())
    .sort((left, right) => left.deliveredAt - right.deliveredAt || left.messageUrn.localeCompare(right.messageUrn))
    .map((message, index) => ({ index, ...message }));
  if (messages.length === 0) {
    throw new EmptyResultError('linkedin thread-snapshot', 'No messages were found in the LinkedIn thread.');
  }
  return { recipientNames, messages };
}

cli({
  site: 'linkedin',
  name: 'thread-snapshot',
  access: 'read',
  description: 'Load a LinkedIn messaging thread and return a structured conversation snapshot',
  domain: LINKEDIN_DOMAIN,
  strategy: Strategy.COOKIE,
  browser: true,
  args: [
    { name: 'thread-url', required: true, help: 'Exact LinkedIn messaging thread URL to open and snapshot' },
    { name: 'max-scrolls', type: 'number', default: 30, help: 'Maximum upward scroll attempts used to request older message pages' },
    { name: 'json', type: 'bool', default: false, help: 'Return only JSON snapshot string in the snapshot_json field' },
  ],
  columns: ['thread_url', 'recipient', 'message_count', 'latest_text', 'snapshot_json'],

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Increase --max-scrolls so pagination captures all message pages
  2. Verify the thread actually contains messages in the LinkedIn UI before snapshotting
  3. Update the library if the Message $type string changed; inspect included[] $type values
  4. Handle EmptyResultError explicitly in your caller so empty threads don't crash your pipeline

Example fix

// before: too few scrolls on a long thread
await cliRun('linkedin thread-snapshot', { 'thread-url': url, 'max-scrolls': 2 });
// after
await cliRun('linkedin thread-snapshot', { 'thread-url': url, 'max-scrolls': 30 });
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check thread has messages by inspecting captured Message entities before invoking
const hasMessages = pages.some(p => p.json?.included?.some(e => e?.$type === 'com.linkedin.messenger.Message'));
if (!hasMessages) throw new EmptyResultLikeError('thread has no snapshot-able messages');

Try / catch

try {
  const snap = await run('linkedin thread-snapshot', { 'thread-url': url });
} catch (err) {
  if (err.name === 'EmptyResultError') {
    return { thread_url: url, message_count: 0, latest_text: null, snapshot_json: null };
  }
  throw err;
}

Prevention

When it happens

Trigger: All entities in `included` have $type values other than com.linkedin.messenger.Message, the container's elements list is empty, or every message was filtered out — e.g. an empty/brand-new thread, or the messages live on pages never captured because max-scrolls was too low.

Common situations: Snapshotting a thread with only connection requests/system content and no actual messages; setting --max-scrolls too low so older messages were never fetched; a LinkedIn schema rename of the Message $type making the filter match nothing.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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