jackwener/OpenCLI · error · ArgumentError

${label} is required

Error message

${label} is required

What it means

ArgumentError thrown by requireStringArg in clis/linkedin/people-search.js when the requested argument normalizes to an empty string. It is the standard guard ensuring a mandatory CLI argument (e.g. --keywords for people search) is present and non-blank before building the search URL.

Source

Thrown at clis/linkedin/people-search.js:16

/**
 * LinkedIn people-search via SSR DOM text-slice. Voyager people-search
 * REST returns HTTP 500 from a web context; LinkedIn renders results
 * server-side now. One navigation per call consumes one CUL query.
 */
import { cli, Strategy } from '@jackwener/opencli/registry';
import { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import { looksLinkedInAuthWall, normalizeWhitespace, unwrapEvaluateResult } from './shared.js';

const LINKEDIN_DOMAIN = 'www.linkedin.com';
const SEARCH_URL_BASE = 'https://www.linkedin.com/search/results/people/';
const MAX_LIMIT = 10;

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

function parseLimit(value) {
    if (value === undefined || value === null || value === '') return 5;
    const limit = Number(value);
    if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {
        throw new ArgumentError(`--limit must be an integer between 1 and ${MAX_LIMIT}`);
    }
    return limit;
}

function buildSearchUrl(keywords) {
    return SEARCH_URL_BASE + '?keywords=' + encodeURIComponent(keywords);
}

function normalizeProfileUrl(value) {
    const raw = normalizeWhitespace(value);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass the keywords argument: linkedin people-search --keywords "software engineer"
  2. Check that the shell variable feeding the flag is non-empty
  3. Quote multi-word keywords so argument parsing receives the full value
  4. Wrap command invocation with a check that required args are set

Example fix

// before
await runCli(['people-search', '--keywords', keywordsVar]); // keywordsVar === ''
// after
if (!keywordsVar.trim()) throw new Error('keywords is required before invoking people-search');
await runCli(['people-search', '--keywords', keywordsVar]);
Defensive patterns

Strategy: validation

Validate before calling

function validateKeywords(args) {
  const value = (args.keywords || '').trim();
  if (!value) throw new Error("keywords is required: pass --keywords \"your search terms\"");
  return value;
}

Try / catch

try {
  const rows = await runCli(['linkedin', 'people-search', '--keywords', kw]);
} catch (err) {
  if (String(err.message).endsWith('is required')) {
    console.error('Usage: people-search --keywords "<terms>"');
    process.exitCode = 2;
  } else throw err;
}

Prevention

When it happens

Trigger: Running linkedin people-search without the keywords argument, or passing only whitespace (" ") which normalizeWhitespace collapses to ''.

Common situations: Forgetting --keywords on the command line; shell variable expansion producing an empty string (keywords="$EMPTY"); quoting mistakes so the flag value never reaches args.

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/d0cef54fd90bdf6f. Report an issue: GitHub.