{"record":{"id":"68602545897bf66e","repo":"argoproj/argo-workflows","slug":"completed-and-running-cannot-be-used-together","errorCode":null,"errorMessage":"--completed and --running cannot be used together","messagePattern":"--completed and --running cannot be used together","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/list.go","lineNumber":146,"sourceCode":"\treturn command\n}\n\nfunc listWorkflows(ctx context.Context, serviceClient workflowpkg.WorkflowServiceClient, flags listFlags) (wfv1.Workflows, error) {\n\tlistOpts := &metav1.ListOptions{\n\t\tLimit: flags.chunkSize,\n\t}\n\tlabelSelector, err := labels.Parse(flags.labels)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif len(flags.status) != 0 {\n\t\treq, _ := labels.NewRequirement(common.LabelKeyPhase, selection.In, flags.status)\n\t\tif req != nil {\n\t\t\tlabelSelector = labelSelector.Add(*req)\n\t\t}\n\t}\n\tif flags.completed && flags.running {\n\t\treturn nil, errors.New(\"--completed and --running cannot be used together\")\n\t}\n\tif flags.completed {\n\t\treq, _ := labels.NewRequirement(common.LabelKeyCompleted, selection.Equals, []string{\"true\"})\n\t\tlabelSelector = labelSelector.Add(*req)\n\t}\n\tif flags.running {\n\t\treq, _ := labels.NewRequirement(common.LabelKeyCompleted, selection.NotEquals, []string{\"true\"})\n\t\tlabelSelector = labelSelector.Add(*req)\n\t}\n\tif flags.resubmitted {\n\t\treq, _ := labels.NewRequirement(common.LabelKeyPreviousWorkflowName, selection.Exists, []string{})\n\t\tlabelSelector = labelSelector.Add(*req)\n\t}\n\tlistOpts.LabelSelector = labelSelector.String()\n\tlistOpts.FieldSelector = flags.fields\n\tvar workflows wfv1.Workflows\n\tfor {\n\t\tlogging.RequireLoggerFromContext(ctx).WithField(\"listOpts\", listOpts).Debug(ctx, \"Listing workflows\")","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/list.go#L128-L164","documentation":"listWorkflows builds a label selector for 'argo list'. The --completed and --running flags map to mutually exclusive label requirements (completed=true vs completed=false), so specifying both is contradictory and rejected before querying the API.","triggerScenarios":"Running 'argo list --completed --running' or invoking listWorkflows programmatically (e.g. from retry/stop/resubmit helpers) with both flags set in the parsed options.","commonSituations":"Scripts merging flag sets that end up with both; users thinking the flags filter different dimensions rather than opposite phases of completion; alias configurations appending both flags.","solutions":["Use only one of --completed or --running.","Drop both flags to list all workflows regardless of completion state.","Sanitize flags in wrapper scripts so they are mutually exclusive."],"exampleFix":"// before\nargo list --completed --running\n// after\nargo list --completed","handlingStrategy":"validation","validationCode":"if [ -n \"$COMPLETED\" ] && [ -n \"$RUNNING\" ]; then\n  echo '--completed and --running are mutually exclusive'; exit 1;\nfi","typeGuard":null,"tryCatchPattern":"if ! argo list --completed --running 2>err.txt; then\n  grep -q 'cannot be used together' err.txt && drop_one_flag\nfi","preventionTips":["Treat --completed/--running as an either/or choice in wrapper scripts.","Build flag arrays conditionally instead of concatenating user input.","Document the exclusivity in script help text."],"tags":["cli","flags","validation"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}