{"record":{"id":"b10501e9ae32b46e","repo":"paperclipai/paperclip","slug":"source-path-or-url-is-required","errorCode":null,"errorMessage":"Source path or URL is required.","messagePattern":"Source path or URL is required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/client/company.ts","lineNumber":1665,"sourceCode":"      .option(\"--target <mode>\", \"Target mode: new | existing\")\n      .option(\"-C, --company-id <id>\", \"Existing target company ID\")\n      .option(\"--new-company-name <name>\", \"Name override for --target new\")\n      .option(\"--agents <list>\", \"Comma-separated agent slugs to import, or all\", \"all\")\n      .option(\"--collision <mode>\", \"Collision strategy: rename | skip | replace\", \"rename\")\n      .option(\"--ref <value>\", \"Git ref to use for GitHub imports (branch, tag, or commit)\")\n      .option(\"--paperclip-url <url>\", \"Alias for --api-base on this command\")\n      .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\"","sourceCodeStart":1647,"sourceCodeEnd":1683,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/client/company.ts#L1647-L1683","documentation":"Thrown at the top of the `company import <fromPathOrUrl>` action when the positional argument, after `.trim()`, is the empty string. It is a pure input-validation guard that runs before any API call or filesystem check. Commander passes the positional as the first action parameter; an empty/whitespace value triggers this.","triggerScenarios":"Running `paperclipai company import` with no positional argument; passing an empty string or whitespace-only argument (e.g. `paperclipai company import \"\"`); a script that interpolates an unset shell variable as the source.","commonSituations":"Copy-pasting a command template but forgetting to fill in the path/URL; a CI job referencing `$IMPORT_SOURCE` when the env var is unset; mistyping the argument order so flags consume the positional slot.","solutions":["Provide a non-empty source: a local directory path or a GitHub repo URL, e.g. `paperclipai company import ./my-export`.","When scripting, guard the variable: `[ -n \"$SRC\" ] || { echo 'source missing'; exit 1; }` before invoking the CLI.","Check Commander argument parsing — ensure flags use `=` or space syntax that does not swallow the positional."],"exampleFix":"# before\npaperclipai company import \"$IMPORT_SOURCE\"\n# after\nSRC=\"${IMPORT_SOURCE:-./company-export}\"\n[ -n \"$SRC\" ] || { echo 'source required'; exit 1; }\npaperclipai company import \"$SRC\"","handlingStrategy":"validation","validationCode":"function resolveImportSource(raw: string | undefined): string {\n  const src = (raw ?? \"\").trim();\n  if (!src) throw new Error(\"Import source (local path or GitHub URL) is required\");\n  return src;\n}\n// Usage before exec:\nconst src = resolveImportSource(process.env.IMPORT_SOURCE);","typeGuard":"function isNonEmptySource(v: unknown): v is string {\n  return typeof v === \"string\" && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["When scripting, default the source to a concrete path and fail fast if unset.","Use shell nounset (`set -u`) so an unset variable errors before the CLI runs.","Validate argument count in wrapper scripts before forwarding to the CLI."],"tags":["cli","validation","import","missing-argument"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}