argoproj/argo-workflows · error
incorrect number of arguments
Error message
incorrect number of arguments
What it means
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.
Source
Thrown at cmd/argo/commands/cp.go:47
artifactName string // --artifact-name
customPath string // --path
)
command := &cobra.Command{
Use: "cp my-wf output-directory ...",
Short: "copy artifacts from workflow",
Example: `# Copy a workflow's artifacts to a local output directory:
argo cp my-wf output-directory
# Copy artifacts from a specific node in a workflow to a local output directory:
argo cp my-wf output-directory --node-id=my-wf-node-id-123
`,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 2 {
cmd.HelpFunc()(cmd, args)
return fmt.Errorf("incorrect number of arguments")
}
workflowName := args[0]
outputDir := args[1]
ctx := cmd.Context()
ctx, apiClient, err := client.NewAPIClient(ctx)
if err != nil {
return err
}
serviceClient := apiClient.NewWorkflowServiceClient(ctx)
if len(namespace) == 0 {
namespace = client.Namespace(ctx)
}
workflow, err := serviceClient.GetWorkflow(ctx, &workflowpkg.WorkflowGetRequest{
Name: workflowName,
Namespace: namespace,
})
if err != nil {View on GitHub (pinned to 35bff19146)
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.
Example fix
// before argo cp my-wf // after argo cp my-wf ./output-directory
Defensive patterns
Strategy: validation
Validate before calling
# shell: check arg count before invoking if [ "$#" -ne 2 ]; then echo "usage: argo cp <workflow> <outdir>"; exit 1; fi argo cp "$1" "$2"
Try / catch
// in Go (exec wrapper)
out, err := exec.Command("argo", "cp", wf, dir).CombinedOutput()
if err != nil && strings.Contains(string(out), "incorrect number of arguments") {
return fmt.Errorf("argo cp needs <workflow> <outdir>: %s", out)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- requires either selector or workflow
- expected labels of the form: NAME1=VALUE2,NAME2=VALUE2. Rece
- expected Annotations of the form: NAME1=VALUE2,NAME2=VALUE2.
- expected parameter of the form: NAME=VALUE. Received: %s
- requires either selector or workflow
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/e3a0a1f78b3aa310.
Report an issue: GitHub.