{"record":{"id":"ba07c7c0b67f850e","repo":"jackwener/OpenCLI","slug":"linkedin-company-extraction-returned-a-malformed-c-ba07c7","errorCode":null,"errorMessage":"LinkedIn company extraction returned a malformed company slug","messagePattern":"LinkedIn company extraction returned a malformed company slug","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/company.js","lineNumber":96,"sourceCode":"    const raw = normalizeWhitespace(value || fallbackUrl);\n    let parsed;\n    try {\n        parsed = new URL(raw, `https://${LINKEDIN_DOMAIN}`);\n    } catch {\n        throw new CommandExecutionError('LinkedIn company extraction returned a malformed current URL');\n    }\n    if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port || !LINKEDIN_COMPANY_HOSTS.has(parsed.hostname.toLowerCase())) {\n        throw new CommandExecutionError('LinkedIn company extraction ended on a non-LinkedIn page');\n    }\n    const match = parsed.pathname.match(COMPANY_URL_RE);\n    if (!match?.[1]) {\n        throw new CommandExecutionError('LinkedIn company extraction ended outside a company page');\n    }\n    let slug;\n    try {\n        slug = decodeURIComponent(match[1]);\n    } catch {\n        throw new CommandExecutionError('LinkedIn company extraction returned a malformed company slug');\n    }\n    return `https://${LINKEDIN_DOMAIN}/company/${encodeURIComponent(slug)}/about/`;\n}\n\nfunction normalizeCompanyInfo(info, targetUrl) {\n    if (!info || typeof info !== 'object' || Array.isArray(info)) {\n        throw new CommandExecutionError('LinkedIn company extraction returned a malformed payload');\n    }\n    if (!info.name) {\n        throw new CommandExecutionError('LinkedIn company page rendered but no company name was found (layout drift or company not found)');\n    }\n    let followers = 0;\n    if (info.followers) {\n        followers = Number(info.followers);\n        if (!Number.isFinite(followers)) {\n            throw new CommandExecutionError('LinkedIn company extraction returned a malformed followers count');\n        }\n    }","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/company.js#L78-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const info = await company({ url: target });\n} catch (err) {\n  if (String(err.message).includes('malformed company slug')) {\n    // retry with the canonical ASCII slug from the company page\n    return company({ url: canonicalCompanyUrl });\n  }\n  throw err;\n}","preventionTips":["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"],"tags":["scraping","encoding","linkedin"],"backgroundTag":"invalid-url-encoding","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}