jackwener/OpenCLI · error · ArgumentError
${label} is required
Error message
${label} is required What it means
requireStringArg is the argument-validation helper for the linkedin connect command. It normalizes whitespace on the given CLI arg and throws ArgumentError when the resulting value is empty, ensuring required string options are present before any browser automation begins.
Source
Thrown at clis/linkedin/connect.js:71
if (url.protocol !== 'https:' || url.username || url.password || url.port || !isLinkedInHost(url.hostname)) return '';
const match = url.pathname.match(/^\/in\/([^/]+)\/?$/i);
if (!match || !match[1]) return '';
// LinkedIn redirects country subdomains (ca./uk./...) to www.; normalize the
// host so an expected `ca.linkedin.com/in/x` matches the landed `www.linkedin.com/in/x`.
url.hostname = 'www.linkedin.com';
url.hash = '';
url.search = '';
if (!url.pathname.endsWith('/')) url.pathname += '/';
return url.toString();
}
catch {
return '';
}
}
function requireStringArg(args, key, label = key) {
const value = normalizeWhitespace(args[key]);
if (!value) throw new ArgumentError(`${label} is required`);
return value;
}
function requireLinkedInProfileUrl(value, label) {
const url = canonicalizeLinkedInProfileUrl(value);
if (!url) throw new ArgumentError(`${label} must be an exact https://www.linkedin.com/in/<profile>/ URL`);
return url;
}
function clampNote(note) {
const value = normalizeWhitespace(note);
if (value.length > 300) throw new ArgumentError('--note must be 300 characters or fewer for LinkedIn connection requests');
return value;
}
function canonicalizeLinkedInInviteUrl(value) {
try {
const url = new URL(normalizeWhitespace(value), 'https://www.linkedin.com');View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the missing flag, e.g. --profile-url https://www.linkedin.com/in/<profile>/ and --expected-name '<Full Name>'
- Check the exact flag spelling (kebab-case) — unknown/misspelled flags fall through as undefined
- Inspect the script/config that builds the command to confirm the variable is non-empty before invocation
- Add an early check in your wrapper script that fails fast with a clear message when a required arg is blank
Example fix
// before node cli.js linkedin connect --expected-name "Jane Doe" // after node cli.js linkedin connect --profile-url "https://www.linkedin.com/in/jane-doe/" --expected-name "Jane Doe"
Defensive patterns
Strategy: validation
Validate before calling
const profileUrl = (args['profile-url'] || '').trim();
const expectedName = (args['expected-name'] || '').trim();
if (!profileUrl) throw new Error('--profile-url is required');
if (!expectedName) throw new Error('--expected-name is required'); Type guard
function hasRequiredArgs(args) { return typeof args['profile-url'] === 'string' && args['profile-url'].trim().length > 0 && typeof args['expected-name'] === 'string' && args['expected-name'].trim().length > 0; } Try / catch
try { await runConnect(args); } catch (e) { if (e instanceof ArgumentError) { console.error(`Missing argument: ${e.message}`); process.exitCode = 2; } else { throw e; } } Prevention
- Validate required flags in a wrapper script before invoking the CLI
- Use exact kebab-case flag names shown in the command's args table
- Avoid passing shell variables without checking they are non-empty
- Fail fast in CI when required inputs are blank
When it happens
Trigger: Running the linkedin connect command without --profile-url, or with an empty/whitespace-only --profile-url or --expected-name value (both are declared required:true).
Common situations: Forgetting a required flag on the CLI; a shell script passing an empty variable; quoting mistakes yielding a whitespace-only value; YAML/JSON config driving the CLI with a missing key.
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
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- dblp ${label} must be a positive integer
- dblp ${label} must be <= ${maxValue}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0ac3a6719bb37ae7.
Report an issue: GitHub.