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

  1. Update the library in case slug handling was patched for this slug pattern
  2. Scrape using the canonical ASCII slug from the company page URL instead of a vanity/encoded variant
  3. 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

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

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/ba07c7c0b67f850e. Report an issue: GitHub.