{"record":{"id":"e3a0a1f78b3aa310","repo":"argoproj/argo-workflows","slug":"incorrect-number-of-arguments","errorCode":null,"errorMessage":"incorrect number of arguments","messagePattern":"incorrect number of arguments","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/cp.go","lineNumber":47,"sourceCode":"\t\tartifactName string // --artifact-name\n\t\tcustomPath   string // --path\n\t)\n\tcommand := &cobra.Command{\n\t\tUse:   \"cp my-wf output-directory ...\",\n\t\tShort: \"copy artifacts from workflow\",\n\t\tExample: `# Copy a workflow's artifacts to a local output directory:\n\n  argo cp my-wf output-directory\n\n# Copy artifacts from a specific node in a workflow to a local output directory:\n\n  argo cp my-wf output-directory --node-id=my-wf-node-id-123\n`,\n\t\tSilenceUsage: true,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) != 2 {\n\t\t\t\tcmd.HelpFunc()(cmd, args)\n\t\t\t\treturn fmt.Errorf(\"incorrect number of arguments\")\n\t\t\t}\n\t\t\tworkflowName := args[0]\n\t\t\toutputDir := args[1]\n\n\t\t\tctx := cmd.Context()\n\t\t\tctx, apiClient, err := client.NewAPIClient(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tserviceClient := apiClient.NewWorkflowServiceClient(ctx)\n\t\t\tif len(namespace) == 0 {\n\t\t\t\tnamespace = client.Namespace(ctx)\n\t\t\t}\n\t\t\tworkflow, err := serviceClient.GetWorkflow(ctx, &workflowpkg.WorkflowGetRequest{\n\t\t\t\tName:      workflowName,\n\t\t\t\tNamespace: namespace,\n\t\t\t})\n\t\t\tif err != nil {","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/cp.go#L29-L65","documentation":"The `argo cp` command requires exactly two positional arguments: the workflow name and the output directory. When a different number is supplied, the help text is printed and this error is returned so the command exits non-zero instead of silently misinterpreting arguments.","triggerScenarios":"Running `argo cp` with zero, one, or three-plus positional arguments, e.g. forgetting the output directory (`argo cp my-wf`) or accidentally passing flag values positionally.","commonSituations":"Copy-pasting examples with line breaks that drop an argument; putting flags after positional args and quoting issues splitting words; forgetting to quote an output directory containing spaces so only part is seen as one arg.","solutions":["Provide both arguments: `argo cp <workflow-name> <output-directory>`.","Quote paths containing spaces: `argo cp my-wf \"/tmp/my output\"`.","Check that flags use `--flag=value` syntax so they are not consumed as positional args.","Run `argo cp --help` to review expected usage."],"exampleFix":"// before\nargo cp my-wf\n// after\nargo cp my-wf ./output-directory","handlingStrategy":"validation","validationCode":"# shell: check arg count before invoking\nif [ \"$#\" -ne 2 ]; then echo \"usage: argo cp <workflow> <outdir>\"; exit 1; fi\nargo cp \"$1\" \"$2\"","typeGuard":null,"tryCatchPattern":"// in Go (exec wrapper)\nout, err := exec.Command(\"argo\", \"cp\", wf, dir).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"incorrect number of arguments\") {\n  return fmt.Errorf(\"argo cp needs <workflow> <outdir>: %s\", out)\n}","preventionTips":["Always quote positional args, especially paths with spaces.","Use `--flag=value` form for flags so they never leak into positionals.","Consult `argo cp --help` in scripts before constructing the command."],"tags":["cli","arguments","usage"],"backgroundTag":"missing-required-argument","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}