{"record":{"id":"8d4e6b94558702b4","repo":"argoproj/argo-workflows","slug":"requires-either-a-workflow-or-other-argument","errorCode":null,"errorMessage":"requires either a workflow or other argument","messagePattern":"requires either a workflow or other argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/argo/commands/delete.go","lineNumber":43,"sourceCode":"\t\thasFilterFlag = func() bool {\n\t\t\treturn all || allNamespaces || flags.completed || flags.resubmitted || flags.prefix != \"\" ||\n\t\t\t\tflags.labels != \"\" || flags.fields != \"\" || flags.finishedBefore != \"\" || len(flags.status) > 0\n\t\t}\n\t)\n\tcommand := &cobra.Command{\n\t\tUse:   \"delete [--dry-run] [WORKFLOW...|[--all] [--older] [--completed] [--resubmitted] [--prefix PREFIX] [--selector SELECTOR] [--force] [--status STATUS] ]\",\n\t\tShort: \"delete workflows\",\n\t\tExample: `# Delete a workflow:\n\n  argo delete my-wf\n\n# Delete the latest workflow:\n\n  argo delete @latest\n`,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif len(args) == 0 && !hasFilterFlag() {\n\t\t\t\treturn errors.New(\"requires either a workflow or other argument\")\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\tvar workflows wfv1.Workflows\n\t\t\tif !allNamespaces {\n\t\t\t\tflags.namespace = client.Namespace(ctx)\n\t\t\t}\n\t\t\tfor _, name := range args {\n\t\t\t\tworkflows = append(workflows, wfv1.Workflow{\n\t\t\t\t\tObjectMeta: metav1.ObjectMeta{Name: name, Namespace: flags.namespace},\n\t\t\t\t})","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/cmd/argo/commands/delete.go#L25-L61","documentation":"The 'argo delete' command requires an explicit target: at least one workflow name argument (including @latest style tokens) or a filter flag like --selector / --all / --completed / --older / --newer. Cobra's Args validator rejects bare 'argo delete' to prevent accidental mass deletion.","triggerScenarios":"Running 'argo delete' with no arguments and no filter flags.","commonSituations":"Scripts where the workflow name variable is empty; users expecting 'argo delete' alone to prompt or delete the latest workflow; forgetting --all or --selector.","solutions":["Name the workflow: argo delete my-wf or use @latest: argo delete @latest.","Use a filter: argo delete --all, --selector workflows.argoproj.io/phase=Failed, or --older 24h.","Guard scripts to substitute a real name before calling delete."],"exampleFix":"// before\nargo delete   # no target -> error\n// after\nargo delete @latest","handlingStrategy":"validation","validationCode":"if [ $# -eq 0 ] && [ -z \"$SELECTOR\" ] && [ -z \"$ALL\" ]; then\n  echo 'argo delete needs a workflow or filter flag'; exit 1;\nfi","typeGuard":null,"tryCatchPattern":"if ! argo delete \"$WF\" 2>err.txt; then\n  grep -q 'requires either a workflow' err.txt && usage_exit\nfi","preventionTips":["Never invoke bare 'argo delete' in scripts; always pass an explicit target.","Use @latest or --selector deliberately with confirmation.","Set empty-variable guards (set -u) in shell scripts."],"tags":["cli","cobra","destructive-command"],"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"}