{"record":{"id":"11799ae313b666d4","repo":"paperclipai/paperclip","slug":"no-company-found-by-id-selector","errorCode":null,"errorMessage":"No company found by ID '${selector}'.","messagePattern":"No company found by ID '(.+?)'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/company.ts","lineNumber":1287,"sourceCode":"  return company.issuePrefix.toUpperCase() === selector.toUpperCase();\n}\n\nexport function resolveCompanyForDeletion(\n  companies: Company[],\n  selectorRaw: string,\n  by: CompanyDeleteSelectorMode = \"auto\",\n): Company {\n  const selector = normalizeSelector(selectorRaw);\n  if (!selector) {\n    throw new Error(\"Company selector is required.\");\n  }\n\n  const idMatch = companies.find((company) => company.id === selector);\n  const prefixMatch = companies.find((company) => matchesPrefix(company, selector));\n\n  if (by === \"id\") {\n    if (!idMatch) {\n      throw new Error(`No company found by ID '${selector}'.`);\n    }\n    return idMatch;\n  }\n\n  if (by === \"prefix\") {\n    if (!prefixMatch) {\n      throw new Error(`No company found by shortname/prefix '${selector}'.`);\n    }\n    return prefixMatch;\n  }\n\n  if (idMatch && prefixMatch && idMatch.id !== prefixMatch.id) {\n    throw new Error(\n      `Selector '${selector}' is ambiguous (matches both an ID and a shortname). Re-run with --by id or --by prefix.`,\n    );\n  }\n\n  if (idMatch) return idMatch;","sourceCodeStart":1269,"sourceCodeEnd":1305,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/company.ts#L1269-L1305","documentation":"Thrown by resolveCompanyForDeletion when by==='id' (or the auto path is forced to id) and no company in the provided list has an id equal to the selector. The lookup is exact and case-sensitive against company.id.","triggerScenarios":"Passing --by id with a selector that is a prefix instead of an id. Typing the id with wrong case, extra whitespace, or a stale id from a deleted company. Calling resolveCompanyForDeletion with a companies list that does not include the target (e.g. wrong tenant/page).","commonSituations":"User copies an issue prefix (PAP) thinking it is the id. The company was deleted by another operator. Pagination meant the target was not in the fetched list. Case mismatch on a case-sensitive id.","solutions":["Run 'paperclipai company list' and copy the exact 'id' value.","If you meant the prefix, use '--by prefix' instead.","Drop --by entirely to let auto-resolution try both id and prefix.","Ensure the companies list passed in is complete (refresh / paginate) before resolving."],"exampleFix":"# before\npaperclipai company delete cmp_ABC --by id --yes --confirm cmp_ABC\n# after (correct id from `company list`)\npaperclipai company delete cmp_abc123 --by id --yes --confirm cmp_abc123","handlingStrategy":"validation","validationCode":"function ensureCompanyById(companies: { id: string }[], selector: string): void {\n  if (!companies.some((c) => c.id === selector)) {\n    throw new Error(`No company with id '${selector}'. Run 'company list'.`);\n  }\n}","typeGuard":"function companyIdExists(companies: { id: string }[], selector: string): boolean {\n  return companies.some((c) => c.id === selector);\n}","tryCatchPattern":null,"preventionTips":["Fetch a fresh, paginated company list before resolving by id.","Copy ids verbatim from list output.","Prefer '--by id' only when you hold the canonical id."],"tags":["cli","validation","company-delete","lookup"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}