argoproj/argo-workflows · error
requires either selector or workflow
Error message
requires either selector or workflow
What it means
`argo stop` needs a target: either workflow name(s) as positional args or a selector (--field-selector / --node-field-selector via stopArgs.hasSelector()). The Args validator at cmd/argo/commands/stop.go:59 rejects invocations with neither, as stopping with no target would be ambiguous.
Source
Thrown at cmd/argo/commands/stop.go:59
Example: `# Stop a workflow:
argo stop my-wf
# Stop the latest workflow:
argo stop @latest
# Stop multiple workflows by label selector
argo stop -l workflows.argoproj.io/test=true
# Stop multiple workflows by field selector
argo stop --field-selector metadata.namespace=argo
`,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 && !stopArgs.hasSelector() {
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)
stopArgs.namespace = client.Namespace(ctx)
return stopWorkflows(ctx, serviceClient, stopArgs, args)
},
}
command.Flags().StringVar(&stopArgs.message, "message", "", "Message to add to previously running nodes")
command.Flags().StringVar(&stopArgs.nodeFieldSelector, "node-field-selector", "", "selector of node to stop, eg: --node-field-selector inputs.parameters.myparam.value=abc")
command.Flags().StringVarP(&stopArgs.labelSelector, "selector", "l", "", "Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)")View on GitHub (pinned to 35bff19146)
Solutions
- Pass workflow names: `argo stop my-wf`
- Or use a selector for bulk stops: `argo stop --field-selector metadata.namespace=argo`
- In scripts, verify the args array is non-empty before invoking argo stop
Example fix
// before argo stop # no target // after argo stop --field-selector metadata.namespace=argo
Defensive patterns
Strategy: validation
Validate before calling
if [ ${#WF_ARGS[@]} -eq 0 ] && [ -z "$FIELD_SELECTOR" ]; then
echo "argo stop: requires either selector or workflow" >&2; exit 2
fi Prevention
- argo stop never acts on a whole namespace without an explicit selector
- Guard empty workflow arrays in bulk-stop scripts
- Prefer --field-selector metadata.namespace=<ns> for intentional bulk stops
When it happens
Trigger: Running `argo stop` with no arguments and no selector flags, e.g. expecting `argo stop` to stop workflows in the current namespace.
Common situations: Confusion with kubectl-style 'apply to namespace' mental models; scripts where the workflow list was empty so args vanished; omitting --field-selector when intending a bulk stop.
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 node field selector or workflow
- requires either node field selector or workflow
- --since-time and --since cannot be used together
- cannot combine --from with file arguments
- cannot watch more than one workflow
AI-assisted analysis of argoproj/argo-workflows@35bff19146 (2026-09-03).
Data as JSON: /api/errors/2ff1dab14eab12f8.
Report an issue: GitHub.