{"record":{"id":"b3459a58ccb0c241","repo":"go-task/task","slug":"task-json-only-applies-to-list-or-list-all","errorCode":null,"errorMessage":"task: --json only applies to --list or --list-all","messagePattern":"task: --json only applies to --list or --list-all","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/flags/flags.go","lineNumber":233,"sourceCode":"\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}\n\n\treturn nil\n}\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/internal/flags/flags.go#L215-L251","documentation":"Flag validation error raised by the Validate function after CLI parsing before task execution. It fires when --json is passed without either --list or --list-all; JSON formatting of task listings is only supported for those two listing modes, so the flag has no effect otherwise. Fix by adding --list or --list-all, or removing --json.","triggerScenarios":"Running `task --no-status` (or with --list/--list-all but without --json) so NoStatus is true while ListJson is false when Validate() executes.","commonSituations":"CI scripts passing --no-status for compact output but missing the required --json --list combination; stale documentation examples.","solutions":["Use `--json --list --no-status` (or --list-all) as the full flag set","Remove --no-status if you don't want JSON list output","Fix scripts so --no-status is only added when --json listing is enabled"],"exampleFix":"# before\ntask --list --no-status\n\n# after\ntask --list --json --no-status","handlingStrategy":"validation","validationCode":"if flags.NoStatus && !flags.ListJson {\n\treturn errors.New(\"--no-status requires --json with --list or --list-all\")\n}","typeGuard":null,"tryCatchPattern":"if err := flags.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"--no-status only applies\") {\n\t\tfmt.Fprintln(os.Stderr, \"use: task --list --json --no-status\")\n\t\tos.Exit(2)\n\t}\n\treturn err\n}","preventionTips":["Use the full combination --json --list --no-status as a unit","Define script constants for the complete JSON-listing flag set","Don't add --no-status for text-mode listings"],"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"}