{"record":{"id":"4c06f2515698e977","repo":"paperclipai/paperclip","slug":"no-company-found-by-id-normalizedselector","errorCode":null,"errorMessage":"No company found by ID '${normalizedSelector}'.","messagePattern":"No company found by ID '(.+?)'\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/company.ts","lineNumber":1947,"sourceCode":"      .action(async (selector: string, opts: CompanyDeleteOptions) => {\n        try {\n          const by = (opts.by ?? \"auto\").trim().toLowerCase() as CompanyDeleteSelectorMode;\n          if (![\"auto\", \"id\", \"prefix\"].includes(by)) {\n            throw new Error(`Invalid --by mode '${opts.by}'. Expected one of: auto, id, prefix.`);\n          }\n\n          const ctx = resolveCommandContext(opts);\n          const normalizedSelector = normalizeSelector(selector);\n          assertDeleteFlags(opts);\n\n          let target: Company | null = null;\n          const shouldTryIdLookup = by === \"id\" || (by === \"auto\" && isUuidLike(normalizedSelector));\n          if (shouldTryIdLookup) {\n            const byId = await ctx.api.get<Company>(apiPath`/api/companies/${normalizedSelector}`, { ignoreNotFound: true });\n            if (byId) {\n              target = byId;\n            } else if (by === \"id\") {\n              throw new Error(`No company found by ID '${normalizedSelector}'.`);\n            }\n          }\n\n          if (!target && ctx.companyId) {\n            const scoped = await ctx.api.get<Company>(apiPath`/api/companies/${ctx.companyId}`, { ignoreNotFound: true });\n            if (scoped) {\n              try {\n                target = resolveCompanyForDeletion([scoped], normalizedSelector, by);\n              } catch {\n                // Fallback to board-wide lookup below.\n              }\n            }\n          }\n\n          if (!target) {\n            try {\n              const companies = (await ctx.api.get<Company[]>(\"/api/companies\")) ?? [];\n              target = resolveCompanyForDeletion(companies, normalizedSelector, by);","sourceCodeStart":1929,"sourceCodeEnd":1965,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/company.ts#L1929-L1965","documentation":"Thrown when --by is 'id' and the GET /api/companies/{selector} lookup (with ignoreNotFound) returned null. Because the user explicitly asserted the selector is an ID, a miss is a hard failure rather than a fallback to prefix resolution. The normalized selector was treated as a UUID.","triggerScenarios":"Running `paperclipai company delete <id> --by id ...` where <id> is not an existing company UUID; a typo in the UUID; the company was already deleted; the authenticated caller lacks read access to that company.","commonSituations":"Stale ID copied from an old list; company deleted in another session; agent-scoped API key trying to delete a company outside its scope (returns 404 via ignoreNotFound).","solutions":["Verify the ID: `paperclipai company list --json` and copy the current id.","Drop `--by id` to let auto/prefix resolution try the selector as a prefix.","Ensure the auth token has access to the target company (board token for cross-company)."],"exampleFix":"# before\npaperclipai company delete 00000000-0000-0000-0000-000000000000 --by id --yes --confirm ...\n# after\nID=$(paperclipai company list --json | jq -r '.[0].id')\npaperclipai company delete \"$ID\" --by id --yes --confirm \"$PREFIX\"","handlingStrategy":"validation","validationCode":"// Confirm the company exists before asserting --by id in a delete.\nasync function companyExistsById(api: { get: (p: string, o?: { ignoreNotFound?: boolean }) => Promise<unknown> }, id: string): Promise<boolean> {\n  const c = await api.get(`/api/companies/${id}`, { ignoreNotFound: true });\n  return c != null;\n}","typeGuard":"import type { Company } from \"@paperclipai/shared\";\n\nfunction isCompany(v: unknown): v is Company {\n  return !!v && typeof v === \"object\" && typeof (v as Company).id === \"string\";\n}","tryCatchPattern":"try {\n  const byId = await ctx.api.get<Company>(`/api/companies/${id}`, { ignoreNotFound: true });\n  if (!isCompany(byId)) throw new Error(`No company found by ID '${id}'`);\n} catch (err) {\n  // Optionally fall back to --by prefix resolution here.\n  throw err;\n}","preventionTips":["Resolve IDs dynamically via `company list --json` rather than hardcoding stale values.","Prefer --by auto so the CLI falls back to prefix when an ID misses.","Ensure the auth token can read the target company."],"tags":["cli","company-delete","not-found","lookup"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}