{"record":{"id":"f02b9571504bb181","repo":"go-task/task","slug":"task-nested-only-applies-to-json-with-list","errorCode":null,"errorMessage":"task: --nested only applies to --json with --list or --list-all","messagePattern":"task: --nested only applies to --json with --list or --list-all","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/flags/flags.go","lineNumber":241,"sourceCode":"\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\n// WithFlags is a special internal functional option that is used to pass flags\n// from the CLI into any constructor that accepts functional options.\nfunc WithFlags() task.ExecutorOption {\n\treturn &flagsOption{}\n}\n\ntype flagsOption struct{}\n","sourceCodeStart":223,"sourceCodeEnd":259,"githubUrl":"https://github.com/go-task/task/blob/385e5ad92af02877b6d7cf9dcc963b5ed916e70a/internal/flags/flags.go#L223-L259","documentation":"Task CLI validates flag combinations in internal/flags.Validate. The --nested flag is only meaningful when machine-readable output is enabled, so it is rejected unless --json is combined with --list or --list-all.","triggerScenarios":"Running `task --nested` (or passing Nested=true via WithFlags) without `--json --list` or `--json --list-all`.","commonSituations":"Users exploring nested task display options copy a --nested example but omit --json/--list, or scripts add --nested to plain `task --list` invocations after upgrading.","solutions":["Add --json together with --list or --list-all when using --nested","Remove --nested if plain (non-JSON) output is intended","If invoked programmatically, set ListJson=true and List/ListAll=true alongside Nested=true before Validate runs"],"exampleFix":"// before\ntask --nested --list\n// after\ntask --nested --json --list","handlingStrategy":"validation","validationCode":"if nested && !(listJSON && (list || listAll)) {\n    // fix args before invoking task\n    args = append(args, \"--json\")\n    if !contains(args, \"--list\") && !contains(args, \"--list-all\") {\n        args = append(args, \"--list\")\n    }\n}","typeGuard":"func nestedFlagsValid(nested, listJSON, list, listAll bool) bool {\n    return !nested || (listJSON && (list || listAll))\n}","tryCatchPattern":null,"preventionTips":["Whenever adding --nested, add --json --list (or --list-all) in the same command","Wrap CLI builders in a function that enforces flag dependencies","Test flag combinations in CI before release"],"tags":["cli","flag-validation","task"],"backgroundTag":"incompatible-flag-combination","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"}