jackwener/OpenCLI · error · ArgumentError

${label} is required

Error message

${label} is required

What it means

thread-snapshot.js defines its own local requireStringArg: it normalizes whitespace on args[key] and throws ArgumentError with `${label} is required` when empty. It enforces required arguments like the thread URL before any scraping begins.

Source

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

import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import {
  canonicalizeLinkedInThreadUrl,
  normalizeWhitespace,
  requireLinkedInCookie,
  unwrapEvaluateResult,
} from './shared.js';

const LINKEDIN_DOMAIN = 'www.linkedin.com';

function requireStringArg(args, key, label = key) {
  const value = normalizeWhitespace(args[key]);
  if (!value) throw new ArgumentError(`${label} is required`);
  return value;
}

function requireLinkedInThreadUrl(value, label) {
  const url = canonicalizeLinkedInThreadUrl(value);
  if (!url) throw new ArgumentError(`${label} must be an exact https://www.linkedin.com/messaging/thread/<id>/ URL`);
  return url;
}

function parseMaxScrolls(value) {
  if (value === undefined || value === null || value === '') return 30;
  const scrolls = Number(value);
  if (!Number.isInteger(scrolls) || scrolls < 0 || scrolls > 80) {
    throw new ArgumentError('--max-scrolls must be an integer between 0 and 80');
  }
  return scrolls;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Provide the required argument, e.g. `--thread-url "https://www.linkedin.com/messaging/thread/<id>/"`.
  2. Check the error's label to see which key was missing.
  3. Validate the source (env var, config) is non-empty before invoking the CLI.
  4. Pass a real thread ID string, not an empty placeholder.

Example fix

// before
node cli.js thread-snapshot --thread-url "$THREAD_URL"   # THREAD_URL unset -> empty
// after
: "${THREAD_URL:?THREAD_URL is required}"
node cli.js thread-snapshot --thread-url "$THREAD_URL"
Defensive patterns

Strategy: validation

Validate before calling

function assertThreadUrlArg(args) {
  const v = typeof args?.['thread-url'] === 'string' ? args['thread-url'].trim() : '';
  if (!v) throw new Error('--thread-url is required');
  return v;
}

Type guard

function hasThreadUrlArg(args) {
  return typeof args?.['thread-url'] === 'string' && args['thread-url'].trim().length > 0;
}

Try / catch

try {
  await threadSnapshot(args);
} catch (e) {
  if (e instanceof ArgumentError && / is required$/.test(e.message)) {
    console.error(`Missing required argument: ${e.message.replace(' is required', '')} (pass --thread-url ...)`);
    process.exitCode = 2;
  } else throw e;
}

Prevention

When it happens

Trigger: Invoking the thread-snapshot command without the thread URL argument, or with an empty/whitespace-only value, e.g. `linkedin thread-snapshot --thread-url ""`.

Common situations: Scripts where the thread URL variable is unset, copy-paste omitted the flag value, or a wrapper passed an empty string after trimming.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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