{"record":{"id":"407fd812079bdfa6","repo":"jackwener/OpenCLI","slug":"linkedin-company-extraction-ended-outside-a-compan","errorCode":null,"errorMessage":"LinkedIn company extraction ended outside a company page","messagePattern":"LinkedIn company extraction ended outside a company page","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/company.js","lineNumber":90,"sourceCode":"      about: about.slice(0, 2000),\n    };\n  })()`;\n}\n\nfunction normalizeCompanyOutputUrl(value, fallbackUrl) {\n    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;","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/company.js#L72-L108","documentation":"Even when the final URL is on linkedin.com, the path must still match COMPANY_URL_RE with a captured slug. If the browser ended outside a /company/<name> path (feed, login, search results, redirected company page), this error is thrown because no company slug can be extracted.","triggerScenarios":"Company page redirected to the LinkedIn feed, authwall, or homepage because the session was unauthenticated or the company does not exist; extraction ran while the SPA was still navigating so location.pathname was not yet /company/...; slug-less URL like /company/ (empty name).","commonSituations":"Deleted/renamed company slug leading LinkedIn to bounce to a search or feed page; rate-limit or authwall interstitial; scraping too early before client-side routing settled.","solutions":["Verify the company slug exists by opening the URL in a browser first","Wait for the SPA to finish navigating before running extraction (or retry the command)","Re-authenticate the scraping session to avoid authwall redirects","Use the canonical /company/<slug>/about/ URL as targetUrl"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"function isCompanyAboutUrl(u) { try { return /\\/company\\/[^/]+/.test(new URL(u).pathname); } catch { return false; } }\n// pre-check the target before invoking\nif (!isCompanyAboutUrl(target)) throw new Error('Target must be a /company/<slug> URL');","typeGuard":null,"tryCatchPattern":"try {\n  const info = await company({ url: target });\n} catch (err) {\n  if (String(err.message).includes('outside a company page')) {\n    await wait(2000); // allow SPA navigation to settle\n    return company({ url: target });\n  }\n  throw err;\n}","preventionTips":["Verify the slug exists by opening the page in a browser first","Wait for page load / SPA routing to settle before extraction","Re-authenticate to avoid authwall redirects to feed or login"],"tags":["scraping","linkedin","navigation"],"backgroundTag":"scrape-extraction-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}