{"record":{"id":"5554c6e3676e6c4f","repo":"jackwener/OpenCLI","slug":"could-not-resolve-linkedin-company-filter-unres","errorCode":null,"errorMessage":"Could not resolve LinkedIn company filter: ${unresolved.join(', ')}","messagePattern":"Could not resolve LinkedIn company filter: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/search.js","lineNumber":239,"sourceCode":"          inp.value = '';\n          inp.dispatchEvent(new Event('input', { bubbles: true }));\n          await sleep(100);\n        }\n      }\n      results[name] = found || null;\n    }\n    return results;\n  })()`);\n    const unresolved = [];\n    for (const name of names) {\n        const id = resolved?.[name];\n        if (id)\n            ids.add(id);\n        else\n            unresolved.push(name);\n    }\n    if (unresolved.length) {\n        throw new ArgumentError(`Could not resolve LinkedIn company filter: ${unresolved.join(', ')}`);\n    }\n    return [...ids];\n}\n// ── Voyager API fetch (runs inside page context for cookie access) ────\nasync function fetchJobCards(page, input) {\n    const MAX_BATCH = 25;\n    const allJobs = [];\n    let offset = input.start;\n    // Read JSESSIONID directly from the cookie store via CDP — zero page.evaluate round-trip\n    const cookies = await page.getCookies({ url: 'https://www.linkedin.com' });\n    const jsession = cookies.find((c) => c.name === 'JSESSIONID')?.value;\n    if (!jsession) {\n        throw new AuthRequiredError(LINKEDIN_DOMAIN, 'LinkedIn JSESSIONID cookie not found. Please sign in to LinkedIn in the browser.');\n    }\n    const csrf = jsession.replace(/^\"|\"$/g, '');\n    while (allJobs.length < input.limit) {\n        const count = Math.min(MAX_BATCH, input.limit - allJobs.length);\n        const apiPath = buildVoyagerUrl(input, offset, count);","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/search.js#L221-L257","documentation":"resolveCompanyIds tries to turn each `--company` value into a LinkedIn company filter ID. Numeric values are accepted directly; non-numeric names are resolved by typing them into the 'Add a company' input in the jobs search 'All filters' panel and reading the resulting suggestion inputs. When a name produces no matching suggestion, it is collected and this ArgumentError is thrown listing all unresolved names.","triggerScenarios":"Running `opencli linkedin search \"engineer\" --company \"Some Company\"` where the name is not numeric and the in-page suggestion flow (click 'All filters', type name, wait 1200ms, read input[name=\"company-filter-value\"] entries) yields no match — either exact or substring — for that name.","commonSituations":"Typo or incorrect casing in the company name; company name too generic or too long for LinkedIn's suggestion matching; LinkedIn UI changed so the 'Add a company' input or company-filter-value inputs no longer exist; page not fully loaded or A/B variant without the All filters panel; using an acronym ('MSFT') instead of the legal name ('Microsoft'); slow network so the 1200ms suggestion wait is insufficient.","solutions":["Find the company's numeric LinkedIn company ID (visible in its company page URL, e.g. /company/12345/) and pass the ID instead of a name — numeric values bypass resolution entirely.","Re-run with the exact company name as it appears in LinkedIn's filter dropdown suggestions.","Split the --company list and re-run to identify which specific names failed, then correct each one.","Retry if the failure was likely a slow suggestion dropdown (timing); if it persists across runs, LinkedIn's DOM likely changed and the resolver needs updating."],"exampleFix":"// before\nopencli linkedin search \"swe\" --company \"msft,Amazon Web Services\"\n// after (use numeric company IDs or exact suggestion names)\nopencli linkedin search \"swe\" --company \"1035,Amazon Web Services\"","handlingStrategy":"validation","validationCode":"// Prefer numeric LinkedIn company IDs — they skip DOM resolution entirely\nconst companies = (process.env.COMPANIES || '').split(',').map(s => s.trim()).filter(Boolean);\nconst nonNumeric = companies.filter(c => !/^\\d+$/.test(c));\nif (nonNumeric.length) {\n  console.warn(`Names will be DOM-resolved (fragile): ${nonNumeric.join(', ')} — prefer numeric IDs from /company/<id>/ URLs`);\n}","typeGuard":"const isCompanyId = (v) => /^\\d+$/.test(String(v).trim());\nconst allCompanyIds = (list) => Array.isArray(list) && list.length > 0 && list.every(isCompanyId);","tryCatchPattern":"try {\n  const rows = await run(['linkedin', 'search', query, '--company', companies.join(',')]);\n} catch (e) {\n  if (/Could not resolve LinkedIn company filter/.test(e.message)) {\n    const bad = e.message.split(':')[1]?.split(',').map(s => s.trim()) ?? [];\n    console.error(`Fix or replace these company names with numeric IDs: ${bad.join(', ')}`);\n  } else throw e;\n}","preventionTips":["Always pass numeric LinkedIn company IDs (from /company/<id>/ URLs) instead of names.","Keep company names exactly as they appear in LinkedIn's filter suggestions.","Avoid very short or very generic names that produce no unambiguous suggestion match.","Wrap company-filtered searches in error handling that surfaces which names failed so they can be corrected."],"tags":["linkedin","argument-validation","company-filter","dom-scraping"],"backgroundTag":"filter-value-not-resolvable","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}