argoproj/argo-workflows · error
--completed and --running cannot be used together
Error message
--completed and --running cannot be used together
What it means
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.
Source
Thrown at cmd/argo/commands/list.go:146
return command
}
func listWorkflows(ctx context.Context, serviceClient workflowpkg.WorkflowServiceClient, flags listFlags) (wfv1.Workflows, error) {
listOpts := &metav1.ListOptions{
Limit: flags.chunkSize,
}
labelSelector, err := labels.Parse(flags.labels)
if err != nil {
return nil, err
}
if len(flags.status) != 0 {
req, _ := labels.NewRequirement(common.LabelKeyPhase, selection.In, flags.status)
if req != nil {
labelSelector = labelSelector.Add(*req)
}
}
if flags.completed && flags.running {
return nil, errors.New("--completed and --running cannot be used together")
}
if flags.completed {
req, _ := labels.NewRequirement(common.LabelKeyCompleted, selection.Equals, []string{"true"})
labelSelector = labelSelector.Add(*req)
}
if flags.running {
req, _ := labels.NewRequirement(common.LabelKeyCompleted, selection.NotEquals, []string{"true"})
labelSelector = labelSelector.Add(*req)
}
if flags.resubmitted {
req, _ := labels.NewRequirement(common.LabelKeyPreviousWorkflowName, selection.Exists, []string{})
labelSelector = labelSelector.Add(*req)
}
listOpts.LabelSelector = labelSelector.String()
listOpts.FieldSelector = flags.fields
var workflows wfv1.Workflows
for {
logging.RequireLoggerFromContext(ctx).WithField("listOpts", listOpts).Debug(ctx, "Listing workflows")View on GitHub (pinned to 35bff19146)
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.
Example fix
// before argo list --completed --running // after argo list --completed
Defensive patterns
Strategy: validation
Validate before calling
if [ -n "$COMPLETED" ] && [ -n "$RUNNING" ]; then echo '--completed and --running are mutually exclusive'; exit 1; fi
Try / catch
if ! argo list --completed --running 2>err.txt; then grep -q 'cannot be used together' err.txt && drop_one_flag fi
Prevention
- 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.
When it happens
Trigger: Running 'argo list --completed --running' or invoking listWorkflows programmatically (e.g. from retry/stop/resubmit helpers) with both flags set in the parsed options.
Common situations: 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.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- ${e.Usage()}
- unable to parse node field selector '%s': %w
- unable to parse node field selector '%s': %w
- unable to parse node field selector '%s': %w
- unable to parse node field selector '%s': %w
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/68602545897bf66e.
Report an issue: GitHub.