{"record":{"id":"b58ef3777fef614c","repo":"go-task/task","slug":"task-cannot-use-list-and-list-all-at-the-same","errorCode":null,"errorMessage":"task: cannot use --list and --list-all at the same time","messagePattern":"task: cannot use --list and --list-all at the same time","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/flags/flags.go","lineNumber":229,"sourceCode":"\n\tif Global && Dir != \"\" {\n\t\treturn errors.New(\"task: You can't set both --global and --dir\")\n\t}\n\n\tif Output.Name != \"group\" {\n\t\tif Output.Group.Begin != \"\" {\n\t\t\treturn errors.New(\"task: You can't set --output-group-begin without --output=group\")\n\t\t}\n\t\tif Output.Group.End != \"\" {\n\t\t\treturn errors.New(\"task: You can't set --output-group-end without --output=group\")\n\t\t}\n\t\tif Output.Group.ErrorOnly {\n\t\t\treturn errors.New(\"task: You can't set --output-group-error-only without --output=group\")\n\t\t}\n\t}\n\n\tif List && ListAll {\n\t\treturn errors.New(\"task: cannot use --list and --list-all at the same time\")\n\t}\n\n\tif ListJson && !List && !ListAll {\n\t\treturn errors.New(\"task: --json only applies to --list or --list-all\")\n\t}\n\n\tif NoStatus && !ListJson {\n\t\treturn errors.New(\"task: --no-status only applies to --json with --list or --list-all\")\n\t}\n\n\tif Nested && !ListJson {\n\t\treturn errors.New(\"task: --nested only applies to --json with --list or --list-all\")\n\t}\n\n\t// Validate certificate flags\n\tif (Cert != \"\" && CertKey == \"\") || (Cert == \"\" && CertKey != \"\") {\n\t\treturn errors.New(\"task: --cert and --cert-key must be provided together\")\n\t}","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/internal/flags/flags.go#L211-L247","documentation":"Flag validation error raised by the Validate function after CLI parsing before task execution. It fires when both --list and --list-all are supplied; these are mutually exclusive task-listing modes (--list shows only called tasks, --list-all shows every task including internal ones), so the tool cannot decide which view to produce. Fix by passing only one of the two flags.","triggerScenarios":"Running `task --json` (or --json with other non-list flags) so ListJson is true while both List and ListAll are false when Validate() executes.","commonSituations":"Scripting attempts to get JSON task output by piping a normal run with --json; assuming --json works like other tools' global output-format flags.","solutions":["Add --list or --list-all alongside --json","Remove --json if you didn't intend to list tasks","Update scripts that expected JSON output from plain task runs"],"exampleFix":"# before\ntask --json\n\n# after\ntask --list --json","handlingStrategy":"validation","validationCode":"if flags.ListJson && !flags.List && !flags.ListAll {\n\treturn errors.New(\"--json requires --list or --list-all\")\n}","typeGuard":null,"tryCatchPattern":"if err := flags.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"--json only applies\") {\n\t\tfmt.Fprintln(os.Stderr, \"--json works only with --list or --list-all\")\n\t\tos.Exit(2)\n\t}\n\treturn err\n}","preventionTips":["Remember --json is a modifier for list commands, not a global output format","Gate --json in scripts behind list intent","Use `task --list --json` for machine-readable task lists"],"tags":["cli","flags","json","go-task"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"385e5ad92af02877b6d7cf9dcc963b5ed916e70a","analyzedAt":"2026-09-05T09:01:05.226Z","contentChangedAt":"2026-09-05T09:01:05.226Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}