{"record":{"id":"7b6a4545657b73c5","repo":"jackwener/OpenCLI","slug":"linkedin-company-extraction-ended-on-a-non-linkedi","errorCode":null,"errorMessage":"LinkedIn company extraction ended on a non-LinkedIn page","messagePattern":"LinkedIn company extraction ended on a non-LinkedIn page","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/company.js","lineNumber":86,"sourceCode":"      founded: facts['founded'] || '',\n      website: facts['website'] || '',\n      specialties: facts['specialties'] || '',\n      followers: followersMatch ? followersMatch[1].replace(/,/g, '') : '',\n      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    }","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/company.js#L68-L104","documentation":"normalizeCompanyOutputUrl requires the extraction's final URL to still be on an allowed linkedin.com host with https, no credentials, and no port. If the browser ended on any other domain — a redirect target, auth provider, or external site — this error is thrown because the result cannot represent a LinkedIn company page.","triggerScenarios":"Company page redirected to an external auth/SSO domain, a bot-protection domain, or linkedin.com opened http with a port or userinfo; the extractor's location value points outside LINKEDIN_COMPANY_HOSTS after a redirect chain.","commonSituations":"Session expired and LinkedIn bounced to an external login flow; corporate proxy or SSO wrapping LinkedIn behind another host; anti-bot middleware redirecting to a challenge domain.","solutions":["Ensure the scraping session is authenticated and cookies are fresh so no external redirect occurs","Check what URL the run actually ended on (network log) and remove whatever caused the off-site redirect","Use a direct https://www.linkedin.com/company/<slug>/ target without proxy wrappers"],"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('non-LinkedIn page')) {\n    // refresh session cookies and avoid proxies/SSO wrappers, then retry\n    await refreshSession();\n    return company({ url: target });\n  }\n  throw err;\n}","preventionTips":["Maintain a valid authenticated LinkedIn session so no external login redirect occurs","Avoid proxy/SSO setups that rewrite LinkedIn behind another host","Monitor redirect chains in your scraper and fail fast on off-site hops"],"tags":["scraping","linkedin","redirect"],"backgroundTag":"unexpected-redirect","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}