jackwener/OpenCLI · error · ArgumentError
${label} must be an exact https://www.linkedin.com/in/<profi
Error message
${label} must be an exact https://www.linkedin.com/in/<profile>/ URL What it means
requireLinkedInProfileUrl canonicalizes the supplied profile URL and rejects anything that is not an exact https://www.linkedin.com/in/<profile>/ URL. The library enforces strict canonical profile URLs so later navigation, matching, and safety checks operate on a predictable target.
Source
Thrown at clis/linkedin/connect.js:77
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');
if (url.protocol !== 'https:' || url.username || url.password || url.port || !isLinkedInHost(url.hostname)) return '';
if (!/^\/preload\/custom-invite\/?$/i.test(url.pathname)) return '';
url.hostname = 'www.linkedin.com';
url.hash = '';
if (!url.pathname.endsWith('/')) url.pathname += '/';
return url.toString();View on GitHub (pinned to 49907e53dc)
Solutions
- Open the profile on desktop LinkedIn and copy the canonical URL: https://www.linkedin.com/in/<profile>/ with the trailing slash
- Strip query strings, tracking params, and sub-paths from the URL
- Replace http:// with https:// and remove any country subdomain or 'www.' variants if the canonicalizer rejects them
- Verify the URL is a person profile (/in/), not a company (/company/) or post link
Example fix
// before --profile-url "http://fr.linkedin.com/in/jane-doe?originalSubdomain=fr" // after --profile-url "https://www.linkedin.com/in/jane-doe/"
Defensive patterns
Strategy: validation
Validate before calling
const PROFILE_URL_RE = /^https:\/\/www\.linkedin\.com\/in\/[A-Za-z0-9\-%_]+\/$/;
if (!PROFILE_URL_RE.test(profileUrl)) throw new Error(`--profile-url must be https://www.linkedin.com/in/<profile>/, got: ${profileUrl}`); Type guard
function isCanonicalLinkedInProfileUrl(v) { try { const u = new URL(v); return u.protocol === 'https:' && u.hostname === 'www.linkedin.com' && /^\/in\/[^/]+\/$/.test(u.pathname) && u.search === '' && u.hash === ''; } catch { return false; } } Try / catch
try { await runConnect(args); } catch (e) { if (String(e.message).includes('must be an exact https://www.linkedin.com/in/')) { console.error('Normalize the URL to https://www.linkedin.com/in/<profile>/'); } else { throw e; } } Prevention
- Always copy profile URLs from desktop LinkedIn and keep the trailing slash
- Strip query params, tracking params, and country subdomains before passing the URL
- Reject non-/in/ URLs (company or post links) in your tooling
- Add the canonical-URL regex to your input validation suite
When it happens
Trigger: Passing --profile-url with: http:// instead of https://, a country-prefixed domain (e.g. linkedin.com or fr.linkedin.com), a trailing path (e.g. /in/jane/details/), missing trailing slash, a vanity name with invalid characters, or a non-profile LinkedIn URL (/company/, /posts/).
Common situations: Copying a profile URL from the mobile app (shares/posts links), from Google search results (tracking params, country TLD), or pasting a logged-out redirect URL instead of the canonical /in/<handle>/ form.
Related errors
- ${label} is required
- ${label} must be a positive integer
- ${label} must be <= ${maxValue}
- ${label} must be a numeric ID
- ${label} cannot be empty
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fbee4a441e95a628.
Report an issue: GitHub.