jackwener/OpenCLI · error · CommandExecutionError
LinkedIn company extraction returned a malformed current URL
Error message
LinkedIn company extraction returned a malformed current URL
What it means
normalizeCompanyOutputUrl parses the current URL reported by the in-page extraction script (or the fallback targetUrl). If the string cannot be parsed as a URL even relative to https://linkedin.com, the library assumes the extraction result is corrupt and throws rather than continuing with garbage.
Source
Thrown at clis/linkedin/company.js:83
industry: facts['industry'] || '',
size: facts['company size'] || '',
headquarters: facts['headquarters'] || '',
founded: facts['founded'] || '',
website: facts['website'] || '',
specialties: facts['specialties'] || '',
followers: followersMatch ? followersMatch[1].replace(/,/g, '') : '',
about: about.slice(0, 2000),
};
})()`;
}
function normalizeCompanyOutputUrl(value, fallbackUrl) {
const raw = normalizeWhitespace(value || fallbackUrl);
let parsed;
try {
parsed = new URL(raw, `https://${LINKEDIN_DOMAIN}`);
} catch {
throw new CommandExecutionError('LinkedIn company extraction returned a malformed current URL');
}
if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port || !LINKEDIN_COMPANY_HOSTS.has(parsed.hostname.toLowerCase())) {
throw new CommandExecutionError('LinkedIn company extraction ended on a non-LinkedIn page');
}
const match = parsed.pathname.match(COMPANY_URL_RE);
if (!match?.[1]) {
throw new CommandExecutionError('LinkedIn company extraction ended outside a company page');
}
let slug;
try {
slug = decodeURIComponent(match[1]);
} catch {
throw new CommandExecutionError('LinkedIn company extraction returned a malformed company slug');
}
return `https://${LINKEDIN_DOMAIN}/company/${encodeURIComponent(slug)}/about/`;
}
function normalizeCompanyInfo(info, targetUrl) {View on GitHub (pinned to 49907e53dc)
Solutions
- Verify the scraper session actually reached the LinkedIn company page (not a login/captcha interstitial)
- Update the library in case the extractor script was fixed for a newer LinkedIn layout
- Retry with an explicit valid fallbackUrl so normalization has a sane base
- Log the raw extraction value to confirm what the in-page script returned
Defensive patterns
Strategy: try-catch
Type guard
function isPlainObject(v) { return v !== null && typeof v === 'object' && !Array.isArray(v); } Try / catch
try {
const info = await company({ url: target });
} catch (err) {
if (String(err.message).includes('malformed current URL')) {
// inspect raw extractor output / retry with a fresh session
return retryWithFallback(target);
}
throw err;
} Prevention
- Keep the library updated so the injected extractor matches current LinkedIn DOM
- Ensure the scraping session reaches the page fully before extraction
- Log raw extraction values in a debug mode to catch corrupt output early
When it happens
Trigger: The page-extraction script returned a non-URL string for the current location (empty garbage, JSON fragments, or whitespace-only after normalization) and fallbackUrl was also unusable; page script executed in an unexpected context returning undefined coerced to 'undefined'.
Common situations: LinkedIn layout drift or a bot-check/login interstitial causing the extractor to grab wrong text; DOM APIs failing in the scraping context so location is read incorrectly; very old extractor output format after a library update.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- LinkedIn company extraction ended on a non-LinkedIn page
- LinkedIn company extraction ended outside a company page
- LinkedIn company extraction returned a malformed company slu
- LinkedIn company extraction returned a malformed payload
- LinkedIn company page rendered but no company name was found
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e657e560bf317954.
Report an issue: GitHub.