go-task/task · error
task: --nested only applies to --json with --list or --list-
Error message
task: --nested only applies to --json with --list or --list-all
What it means
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.
Source
Thrown at internal/flags/flags.go:241
if Output.Group.ErrorOnly {
return errors.New("task: You can't set --output-group-error-only without --output=group")
}
}
if List && ListAll {
return errors.New("task: cannot use --list and --list-all at the same time")
}
if ListJson && !List && !ListAll {
return errors.New("task: --json only applies to --list or --list-all")
}
if NoStatus && !ListJson {
return errors.New("task: --no-status only applies to --json with --list or --list-all")
}
if Nested && !ListJson {
return errors.New("task: --nested only applies to --json with --list or --list-all")
}
// Validate certificate flags
if (Cert != "" && CertKey == "") || (Cert == "" && CertKey != "") {
return errors.New("task: --cert and --cert-key must be provided together")
}
return nil
}
// WithFlags is a special internal functional option that is used to pass flags
// from the CLI into any constructor that accepts functional options.
func WithFlags() task.ExecutorOption {
return &flagsOption{}
}
type flagsOption struct{}
View on GitHub (pinned to 385e5ad92a)
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
Example fix
// before task --nested --list // after task --nested --json --list
Defensive patterns
Strategy: validation
Validate before calling
if nested && !(listJSON && (list || listAll)) {
// fix args before invoking task
args = append(args, "--json")
if !contains(args, "--list") && !contains(args, "--list-all") {
args = append(args, "--list")
}
} Type guard
func nestedFlagsValid(nested, listJSON, list, listAll bool) bool {
return !nested || (listJSON && (list || listAll))
} Prevention
- 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
When it happens
Trigger: Running `task --nested` (or passing Nested=true via WithFlags) without `--json --list` or `--json --list-all`.
Common situations: 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.
Related errors
- task: --cert and --cert-key must be provided together
- task: You can't set both --download and --offline flags
- task: You can't set both --download and --clear-cache flags
- task: You can't set both --global and --dir
- task: You can't set --output-group-begin without --output=gr
AI-assisted analysis of go-task/task@385e5ad92a (2026-09-05).
Data as JSON: /api/errors/f02b9571504bb181.
Report an issue: GitHub.