{"record":{"id":"2ff1dab14eab12f8","repo":"argoproj/argo-workflows","slug":"requires-either-selector-or-workflow-2ff1da","errorCode":null,"errorMessage":"requires either selector or workflow","messagePattern":"requires either selector or workflow","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/stop.go","lineNumber":59,"sourceCode":"\t\tExample: `# Stop a workflow:\n\n  argo stop my-wf\n\n# Stop the latest workflow:\n\n  argo stop @latest\n\n# Stop multiple workflows by label selector\n\n  argo stop -l workflows.argoproj.io/test=true\n\n# Stop multiple workflows by field selector\n\n  argo stop --field-selector metadata.namespace=argo\n`,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) == 0 && !stopArgs.hasSelector() {\n\t\t\t\treturn errors.New(\"requires either selector or workflow\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tctx := cmd.Context()\n\t\t\tctx, apiClient, err := client.NewAPIClient(ctx)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tserviceClient := apiClient.NewWorkflowServiceClient(ctx)\n\t\t\tstopArgs.namespace = client.Namespace(ctx)\n\n\t\t\treturn stopWorkflows(ctx, serviceClient, stopArgs, args)\n\t\t},\n\t}\n\tcommand.Flags().StringVar(&stopArgs.message, \"message\", \"\", \"Message to add to previously running nodes\")\n\tcommand.Flags().StringVar(&stopArgs.nodeFieldSelector, \"node-field-selector\", \"\", \"selector of node to stop, eg: --node-field-selector inputs.parameters.myparam.value=abc\")\n\tcommand.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)\")","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/stop.go#L41-L77","documentation":"`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.","triggerScenarios":"Running `argo stop` with no arguments and no selector flags, e.g. expecting `argo stop` to stop workflows in the current namespace.","commonSituations":"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.","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"],"exampleFix":"// before\nargo stop   # no target\n// after\nargo stop --field-selector metadata.namespace=argo","handlingStrategy":"validation","validationCode":"if [ ${#WF_ARGS[@]} -eq 0 ] && [ -z \"$FIELD_SELECTOR\" ]; then\n  echo \"argo stop: requires either selector or workflow\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","argument-validation","argo-cli","stop"],"backgroundTag":"missing-required-argument","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"}