jackwener/OpenCLI · error · ArgumentError
${label} must be a LinkedIn URL
Error message
${label} must be a LinkedIn URL What it means
assertSafeLinkedinUrl parses the supplied URL against https://www.linkedin.com and throws ArgumentError when parsing fails entirely — the value is not a valid URL at all. This is the first gate of the LinkedIn URL safety validation used by commands like services-read.
Source
Thrown at clis/linkedin/shared.js:93
}
return text;
}
export function looksLinkedInAuthWall(value) {
const text = normalizeWhitespace(value).toLowerCase();
if (!text) return false;
return /linkedin\.com\/(?:login|checkpoint|authwall|uas)/i.test(text)
|| /\b(sign in|log in|join linkedin|captcha|verification required)\b/i.test(text)
|| /(请登录|登录领英|安全验证)/.test(text);
}
export function assertSafeLinkedinUrl(value, label, fallbackPath = '/') {
const raw = normalizeWhitespace(value || `https://www.linkedin.com${fallbackPath}`);
let parsed;
try {
parsed = new URL(raw, 'https://www.linkedin.com');
} catch {
throw new ArgumentError(`${label} must be a LinkedIn URL`);
}
const host = parsed.hostname.toLowerCase();
if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port) {
throw new ArgumentError(`${label} must be an https LinkedIn URL without credentials or port`);
}
if (host !== 'linkedin.com' && host !== 'www.linkedin.com') {
throw new ArgumentError(`${label} must point to linkedin.com`);
}
return parsed.toString();
}
export function requireStringArg(args, key, label = key) {
const value = normalizeWhitespace(args?.[key]);
if (!value) throw new ArgumentError(`${label} is required`);
return value;
}
export function parseLimit(value, fallback, max) {View on GitHub (pinned to 49907e53dc)
Solutions
- Validate the URL string with new URL(value, 'https://www.linkedin.com') before calling the command.
- Pass a full absolute https URL, e.g. https://www.linkedin.com/in/<handle>/.
- If the value comes from config/env, log and sanitize it (trim, percent-encode) before passing.
Example fix
// before
await runCommand('linkedin services-read', ['--profile-url', 'https://']);
// after
await runCommand('linkedin services-read', ['--profile-url', 'https://www.linkedin.com/in/jane-doe/']); Defensive patterns
Strategy: validation
Validate before calling
function parseLinkedinUrl(v) {
try { return new URL(String(v).trim(), 'https://www.linkedin.com'); }
catch { throw new Error('profile-url/services-url must be a valid URL'); }
} Type guard
function isValidUrl(v) {
try { new URL(String(v), 'https://www.linkedin.com'); return true; } catch { return false; }
} Prevention
- Validate URLs from env/config at startup, fail fast with a clear message.
- Trim and sanitize shell-supplied arguments before passing them.
- Build URLs programmatically instead of hand-typing them.
When it happens
Trigger: Passing a value that cannot be parsed by `new URL(raw, 'https://www.linkedin.com')`, e.g. a whitespace-free garbage string like '::::' or '%zz', or an empty label with no fallback applied (empty values fall back to https://www.linkedin.com<fallbackPath>, so pure emptiness does not trigger this).
Common situations: Typos in config/env-provided URLs; passing a raw handle like 'jane-doe' is accepted (resolved relative to linkedin.com) but fragments like 'https://' alone or 'http\x' fail; quoting/space issues in shell args are normalized away, leaving invalid remnants.
Related errors
- job-url must be a https://www.linkedin.com/jobs/view/<id> UR
- Sales Navigator lead URL must contain resolved profileId, au
- LinkedIn services-read requires a /in/<handle>/ profile URL
- LinkedIn services-read requires a /services/page/<id>/ URL
- ${label} must be an https LinkedIn URL without credentials o
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4b5b95b01d8639a0.
Report an issue: GitHub.