{"record":{"id":"aa0a95dae133e4e5","repo":"paperclipai/paperclip","slug":"selector-selector-is-ambiguous-matches-both","errorCode":null,"errorMessage":"Selector '${selector}' is ambiguous (matches both an ID and a shortname). Re-run with --by id or --by prefix.","messagePattern":"Selector '(.+?)' is ambiguous \\(matches both an ID and a shortname\\)\\. Re-run with --by id or --by prefix\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/company.ts","lineNumber":1300,"sourceCode":"  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;\n  if (prefixMatch) return prefixMatch;\n\n  throw new Error(\n    `No company found for selector '${selector}'. Use company ID or issue prefix (for example PAP).`,\n  );\n}\n\nexport function assertDeleteConfirmation(company: Company, opts: CompanyDeleteOptions): void {\n  if (!opts.yes) {\n    throw new Error(\"Deletion requires --yes.\");\n  }\n\n  const confirm = opts.confirm?.trim();","sourceCodeStart":1282,"sourceCodeEnd":1318,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/company.ts#L1282-L1318","documentation":"Thrown by resolveCompanyForDeletion in auto mode when the selector matches both a company id and a different company's issue prefix. Without --by, the resolver cannot decide which company to target, so it refuses and asks the caller to disambiguate.","triggerScenarios":"A selector like 'PAP' that is simultaneously a company's issue prefix and another company's id (e.g. an id that happens to read 'PAP'). Auto mode with by='auto' (default) and both lookups hit different rows.","commonSituations":"Short ids or prefixes that collide across the company set. Renamed prefixes that now match an existing id. Multi-tenant setups where prefixes and ids overlap by coincidence.","solutions":["Re-run with '--by id' to target the company whose id matches.","Re-run with '--by prefix' to target the company whose issue prefix matches.","Use a longer/unique selector (full company id) to avoid the collision entirely.","If collisions are frequent, consider renaming a prefix to avoid overlap."],"exampleFix":"# before\npaperclipai company delete PAP --yes --confirm PAP   # ambiguous\n# after\npaperclipai company delete PAP --by prefix --yes --confirm PAP","handlingStrategy":"validation","validationCode":"function detectAmbiguousSelector(companies: { id: string; issuePrefix: string }[], selector: string): void {\n  const idMatch = companies.find((c) => c.id === selector);\n  const prefixMatch = companies.find((c) => c.issuePrefix.toUpperCase() === selector.toUpperCase());\n  if (idMatch && prefixMatch && idMatch.id !== prefixMatch.id) {\n    throw new Error(`Selector '${selector}' is ambiguous. Specify --by id or --by prefix.`);\n  }\n}","typeGuard":"function selectorIsUnambiguous(companies: { id: string; issuePrefix: string }[], selector: string): boolean {\n  const idMatch = companies.find((c) => c.id === selector);\n  const prefixMatch = companies.find((c) => c.issuePrefix.toUpperCase() === selector.toUpperCase());\n  return !(idMatch && prefixMatch && idMatch.id !== prefixMatch.id);\n}","tryCatchPattern":null,"preventionTips":["Default to '--by id' with full ids to sidestep collisions entirely.","Rename prefixes that collide with any company id.","Warn operators when prefix and id namespaces overlap."],"tags":["cli","validation","company-delete","ambiguous","lookup"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}