{"record":{"id":"6cd413dc50720769","repo":"paperclipai/paperclip","slug":"invalid-collision-value-use-rename-skip-repl","errorCode":null,"errorMessage":"Invalid --collision value. Use: rename, skip, replace","messagePattern":"Invalid --collision value\\. Use: rename, skip, replace","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/company.ts","lineNumber":1672,"sourceCode":"      .option(\"--yes\", \"Accept default selection and skip the pre-import confirmation prompt\", false)\n      .option(\"--dry-run\", \"Run preview only without applying\", false)\n      .action(async (fromPathOrUrl: string, opts: CompanyImportOptions) => {\n        try {\n          if (!opts.apiBase?.trim() && opts.paperclipUrl?.trim()) {\n            opts.apiBase = opts.paperclipUrl.trim();\n          }\n          const ctx = resolveCommandContext(opts);\n          const interactiveView = isInteractiveTerminal() && !ctx.json;\n          const from = fromPathOrUrl.trim();\n          if (!from) {\n            throw new Error(\"Source path or URL is required.\");\n          }\n\n          const include = resolveImportInclude(opts.include);\n          const agents = parseAgents(opts.agents);\n          const collision = (opts.collision ?? \"rename\").toLowerCase() as CompanyCollisionMode;\n          if (![\"rename\", \"skip\", \"replace\"].includes(collision)) {\n            throw new Error(\"Invalid --collision value. Use: rename, skip, replace\");\n          }\n\n          const inferredTarget = opts.target ?? (opts.companyId || ctx.companyId ? \"existing\" : \"new\");\n          const target = inferredTarget.toLowerCase() as CompanyImportTargetMode;\n          if (![\"new\", \"existing\"].includes(target)) {\n            throw new Error(\"Invalid --target value. Use: new | existing\");\n          }\n\n          const existingTargetCompanyId = opts.companyId?.trim() || ctx.companyId;\n          const targetPayload =\n            target === \"existing\"\n              ? {\n                  mode: \"existing_company\" as const,\n                  companyId: existingTargetCompanyId,\n                }\n              : {\n                  mode: \"new_company\" as const,\n                  newCompanyName: opts.newCompanyName?.trim() || null,","sourceCodeStart":1654,"sourceCodeEnd":1690,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/company.ts#L1654-L1690","documentation":"Thrown when `opts.collision` (defaulted to \"rename\", lowercased) is not one of 'rename', 'skip', 'replace'. This validates the --collision flag that controls how the import reconciles name collisions with existing companies. The check runs before any network call.","triggerScenarios":"Passing `--collision overwrite`, `--collision merge`, or any typo like `--collision renam`; passing a value from an env var or config that was misspelled.","commonSituations":"Developer guesses a flag value instead of checking `--help`; a script copies a flag value from a different tool's vocabulary (overwrite/merge); tab-completion or shell history inserting a wrong token.","solutions":["Use exactly one of: `--collision rename`, `--collision skip`, or `--collision replace`.","Run `paperclipai company import --help` to confirm the accepted values.","If the value comes from a variable, validate it against the allow-list before the CLI call."],"exampleFix":"// before\nconst collision = process.env.COLLISION ?? \"overwrite\";\n// after\nconst allowed = [\"rename\", \"skip\", \"replace\"] as const;\nconst collision = allowed.includes(process.env.COLLISION as any) ? process.env.COLLISION : \"rename\";","handlingStrategy":"validation","validationCode":"const COLLISION_MODES = [\"rename\", \"skip\", \"replace\"] as const;\ntype CollisionMode = typeof COLLISION_MODES[number];\nfunction normalizeCollision(v: string | undefined): CollisionMode {\n  const lower = (v ?? \"rename\").trim().toLowerCase();\n  if (!COLLISION_MODES.includes(lower as CollisionMode)) {\n    throw new Error(`Invalid collision mode '${v}'; expected one of ${COLLISION_MODES.join(\", \")}`);\n  }\n  return lower as CollisionMode;\n}","typeGuard":"function isCollisionMode(v: unknown): v is \"rename\" | \"skip\" | \"replace\" {\n  return typeof v === \"string\" && [\"rename\", \"skip\", \"replace\"].includes(v.toLowerCase());\n}","tryCatchPattern":null,"preventionTips":["Centralize flag-value allow-lists in a shared config so wrappers and CLI agree.","Prefer omitting --collision to accept the 'rename' default rather than guessing.","Add a unit test over the allowed values for any wrapper."],"tags":["cli","validation","import","invalid-flag"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}