{"record":{"id":"17858c23b5cbdec7","repo":"argoproj/argo-workflows","slug":"requires-either-selector-or-workflow-17858c","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/terminate.go","lineNumber":67,"sourceCode":"\t\tExample: `# Terminate a workflow:\n\n  argo terminate my-wf\n\n# Terminate the latest workflow:\n\n  argo terminate @latest\n\n# Terminate multiple workflows by label selector\n\n  argo terminate -l workflows.argoproj.io/test=true\n\n# Terminate multiple workflows by field selector\n\n  argo terminate --field-selector metadata.namespace=argo\n`,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) == 0 && !t.isList() {\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\tt.namespace = client.Namespace(ctx)\n\n\t\t\tvar workflows wfv1.Workflows\n\n\t\t\tif t.isList() {\n\t\t\t\tlisted, err := listWorkflows(ctx, serviceClient, listFlags{\n\t\t\t\t\tnamespace: t.namespace,\n\t\t\t\t\tfields:    t.fields,","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/terminate.go#L49-L85","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Pass workflow names: `argo terminate my-wf my-wf2` or `argo terminate @latest`.","Use a label selector: `argo terminate -l workflows.argoproj.io/test=true`.","Use a field selector: `argo terminate --field-selector metadata.namespace=argo`.","If the command is generated programmatically, ensure either args or the selector flag is always populated."],"exampleFix":"// before\nargo terminate\n// after\nargo terminate -l workflows.argoproj.io/test=true\n# or\nargo terminate my-wf","handlingStrategy":"validation","validationCode":"if len(args) == 0 && selector == \"\" && fieldSelector == \"\" {\n    return fmt.Errorf(\"terminate needs workflow names or -l/--field-selector\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass workflow names or a selector to terminate","Use `argo terminate @latest` for the most recent workflow","In scripts, default to a label selector when no names are provided"],"tags":["cli","argo","usage"],"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"}