{"record":{"id":"ba82f224667d5afd","repo":"jackwener/OpenCLI","slug":"linkedin-company-requires-a-company-universal-name","errorCode":null,"errorMessage":"LinkedIn company requires a company universal name or URL","messagePattern":"LinkedIn company requires a company universal name or URL","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/company.js","lineNumber":19,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { CommandExecutionError } from '@jackwener/opencli/errors';\nimport {\n    LINKEDIN_DOMAIN,\n    assertLinkedInAuthenticated,\n    normalizeWhitespace,\n    unwrapEvaluateResult,\n} from './shared.js';\n\nconst SLUG_RE = /^[A-Za-z0-9%._-]+$/;\nconst COMPANY_URL_RE = /^\\/company\\/([^/?#]+)/;\nconst LINKEDIN_COMPANY_HOSTS = new Set(['linkedin.com', LINKEDIN_DOMAIN]);\n\n// Accept a bare universal name (`nvidia`), a `/company/<slug>` path, or a full\n// company URL, and return the canonical about-page URL.\nfunction normalizeCompanyUrl(value) {\n    const raw = normalizeWhitespace(value || '');\n    if (!raw) {\n        throw new CommandExecutionError('LinkedIn company requires a company universal name or URL');\n    }\n    let slug = raw;\n    if (/^https?:\\/\\//i.test(raw) || raw.startsWith('/company/')) {\n        let parsed;\n        try {\n            parsed = raw.startsWith('/') ? new URL(raw, `https://${LINKEDIN_DOMAIN}`) : new URL(raw);\n        } catch {\n            throw new CommandExecutionError(`LinkedIn company received a malformed URL: ${raw}`);\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 URL must point to linkedin.com');\n        }\n        const m = parsed.pathname.match(COMPANY_URL_RE);\n        if (!m) throw new CommandExecutionError('LinkedIn company URL must look like /company/<name>');\n        try {\n            slug = decodeURIComponent(m[1]);\n        } catch {\n            throw new CommandExecutionError(`LinkedIn company URL has a malformed company slug: ${m[1]}`);","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/company.js#L1-L37","documentation":"normalizeCompanyUrl validates its input before building the company about-page URL: after whitespace normalization an empty string is rejected with CommandExecutionError. The library requires either a bare universal name (e.g. 'nvidia'), a /company/<slug> path, or a full LinkedIn company URL.","triggerScenarios":"Calling the linkedin company command/targetUrl with an empty, whitespace-only, or undefined argument (e.g. missing CLI arg, variable that resolved to empty string).","commonSituations":"Script passing an empty env var or unbound lookup result; forgetting the positional CLI argument; upstream data pipeline emitting blank company fields.","solutions":["Pass the company universal name or URL, e.g. `linkedin company nvidia` or https://www.linkedin.com/company/nvidia/.","Validate the argument is a non-empty string before invoking the command.","Fix the upstream data source emitting empty values (env var, config, CSV column)."],"exampleFix":"// before\nconst name = process.env.COMPANY; // ''\nawait run(`linkedin company ${name}`); // throws\n// after\nif (!process.env.COMPANY) throw new Error('COMPANY env var required');\nawait run(`linkedin company ${process.env.COMPANY}`);","handlingStrategy":"validation","validationCode":"function requireCompanyInput(value) {\n  const v = (value || '').trim();\n  if (!v) throw new Error('company universal name or URL required');\n  return v;\n}\nawait run(`linkedin company ${requireCompanyInput(arg)}`);","typeGuard":"function hasCompanyInput(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await run(`linkedin company ${arg}`);\n} catch (e) {\n  if (/requires a company universal name or URL/.test(e.message)) {\n    throw new UsageError('Usage: linkedin company <slug|url>');\n  }\n  throw e;\n}","preventionTips":["Validate CLI args / env vars are non-empty before calling.","Guard upstream data pipelines against blank company fields.","Default to a known slug when input is missing in batch jobs."],"tags":["validation","argument-error","cli"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}