jackwener/OpenCLI · error · CommandExecutionError
LinkedIn company extraction returned a malformed company slu
Error message
LinkedIn company extraction returned a malformed company slug
What it means
The slug captured from the extraction's final URL is percent-decoded; if decodeURIComponent throws due to invalid escape sequences, this error is thrown. It mirrors the input-side slug error but fires on data returned by the scraper rather than user input.
Source
Thrown at clis/linkedin/company.js:96
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) {
if (!info || typeof info !== 'object' || Array.isArray(info)) {
throw new CommandExecutionError('LinkedIn company extraction returned a malformed payload');
}
if (!info.name) {
throw new CommandExecutionError('LinkedIn company page rendered but no company name was found (layout drift or company not found)');
}
let followers = 0;
if (info.followers) {
followers = Number(info.followers);
if (!Number.isFinite(followers)) {
throw new CommandExecutionError('LinkedIn company extraction returned a malformed followers count');
}
}View on GitHub (pinned to 49907e53dc)
Solutions
- Update the library in case slug handling was patched for this slug pattern
- Scrape using the canonical ASCII slug from the company page URL instead of a vanity/encoded variant
- Re-run the command; if transient, the extractor may have captured a mid-navigation URL
Defensive patterns
Strategy: try-catch
Try / catch
try {
const info = await company({ url: target });
} catch (err) {
if (String(err.message).includes('malformed company slug')) {
// retry with the canonical ASCII slug from the company page
return company({ url: canonicalCompanyUrl });
}
throw err;
} Prevention
- Use canonical ASCII slugs rather than vanity URLs with encoded characters
- Avoid middleware that rewrites or re-encodes the URL path
- Keep the library updated for slug-handling fixes
When it happens
Trigger: LinkedIn's page location contained a path segment with a malformed percent-escape (broken encoding in a company vanity URL), causing the extractor's slug to fail decoding.
Common situations: Unusual company vanity slugs containing encoded characters that got double-encoded or corrupted by a proxy; scraping through a middleware that rewrites the URL path incorrectly.
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 URL has a malformed company slug: ${m[1]}
- LinkedIn company extraction returned a malformed current URL
- LinkedIn company extraction ended on a non-LinkedIn page
- LinkedIn company extraction ended outside a company page
- LinkedIn company extraction returned a malformed payload
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/ba07c7c0b67f850e.
Report an issue: GitHub.