argoproj/argo-workflows · error

requires either selector or workflow

Error message

requires either selector or workflow

What it means

The `argo terminate` command needs a target: either workflow name arguments or a selector flag (-l/--selector, --field-selector). The Args validator rejects the invocation when no positional args are given and no list selector is set, since terminate would otherwise have nothing to act on.

Source

Thrown at cmd/argo/commands/terminate.go:67

		Example: `# Terminate a workflow:

  argo terminate my-wf

# Terminate the latest workflow:

  argo terminate @latest

# Terminate multiple workflows by label selector

  argo terminate -l workflows.argoproj.io/test=true

# Terminate multiple workflows by field selector

  argo terminate --field-selector metadata.namespace=argo
`,
		Args: func(cmd *cobra.Command, args []string) error {
			if len(args) == 0 && !t.isList() {
				return errors.New("requires either selector or workflow")
			}
			return nil
		},
		RunE: func(cmd *cobra.Command, args []string) error {
			ctx := cmd.Context()
			ctx, apiClient, err := client.NewAPIClient(ctx)
			if err != nil {
				return err
			}
			serviceClient := apiClient.NewWorkflowServiceClient(ctx)
			t.namespace = client.Namespace(ctx)

			var workflows wfv1.Workflows

			if t.isList() {
				listed, err := listWorkflows(ctx, serviceClient, listFlags{
					namespace: t.namespace,
					fields:    t.fields,

View on GitHub (pinned to 35bff19146)

Solutions

  1. Pass workflow names: `argo terminate my-wf my-wf2` or `argo terminate @latest`.
  2. Use a label selector: `argo terminate -l workflows.argoproj.io/test=true`.
  3. Use a field selector: `argo terminate --field-selector metadata.namespace=argo`.
  4. If the command is generated programmatically, ensure either args or the selector flag is always populated.

Example fix

// before
argo terminate
// after
argo terminate -l workflows.argoproj.io/test=true
# or
argo terminate my-wf
Defensive patterns

Strategy: validation

Validate before calling

if len(args) == 0 && selector == "" && fieldSelector == "" {
    return fmt.Errorf("terminate needs workflow names or -l/--field-selector")
}

Prevention

When it happens

Trigger: Running bare `argo terminate` or `argo terminate` with only namespace/other flags but no workflow names and no -l/--field-selector, so len(args)==0 and t.isList() is false.

Common situations: Typing terminate without arguments expecting an interactive picker; dropping the workflow name from a script; intending bulk termination but forgetting the -l or --field-selector flag (note: --field-selector must actually be passed; other flags alone don't satisfy isList).

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


AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03). Data as JSON: /api/errors/17858c23b5cbdec7. Report an issue: GitHub.