{"record":{"id":"460088f9441310ae","repo":"go-delve/delve","slug":"not-enough-arguments-after-chan","errorCode":null,"errorMessage":"not enough arguments after -chan","messagePattern":"not enough arguments after -chan","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/api/command.go","lineNumber":106,"sourceCode":"\t\t\tvar err error\n\t\t\tgroup.GroupBy, err = readGoroutinesFilterKind(args, i+1)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, GoroutineGroupingOptions{}, 0, 0, 0, 0, \"\", fmt.Errorf(\"wrong argument: '%s'\", arg)\n\t\t\t}\n\t\t\ti++\n\t\t\tif group.GroupBy == GoroutineLabel {\n\t\t\t\tif i+1 >= len(args) {\n\t\t\t\t\treturn nil, GoroutineGroupingOptions{}, 0, 0, 0, 0, \"\", fmt.Errorf(\"wrong argument: '%s'\", arg)\n\t\t\t\t}\n\t\t\t\tgroup.GroupByKey = args[i+1]\n\t\t\t\ti++\n\t\t\t}\n\t\t\tbatchSize = 0 // grouping only works well if run on all goroutines\n\n\t\tcase \"-chan\":\n\t\t\ti++\n\t\t\tif i >= len(args) {\n\t\t\t\treturn nil, GoroutineGroupingOptions{}, 0, 0, 0, 0, \"\", errors.New(\"not enough arguments after -chan\")\n\t\t\t}\n\t\t\tfilters = append(filters, ListGoroutinesFilter{Kind: GoroutineWaitingOnChannel, Arg: args[i]})\n\n\t\tcase \"-exec\":\n\t\t\tflags |= PrintGoroutinesExec\n\t\t\tcmd = strings.Join(args[i+1:], \" \")\n\t\t\ti = len(args)\n\n\t\tcase \"\":\n\t\t\t// nothing to do\n\t\tdefault:\n\t\t\treturn nil, GoroutineGroupingOptions{}, 0, 0, 0, 0, \"\", fmt.Errorf(\"wrong argument: '%s'\", arg)\n\t\t}\n\t}\n\treturn filters, group, fgl, flags, depth, batchSize, cmd, nil\n}\n\nfunc readGoroutinesFilterKind(args []string, i int) (GoroutineField, error) {","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/api/command.go#L88-L124","documentation":"ParseGoroutineArgs parses arguments to the goroutines command. The -chan flag expects a following channel expression; when -chan is the last token (i >= len(args) after the increment), there is no filter value and parsing fails with this error. It guards ListGoroutinesFilter construction from a missing argument.","triggerScenarios":"Invoking `goroutines -chan` with nothing after the flag, e.g. typing `goroutines -chan` at the dlv prompt or calling the RPC/API path where args ends with \"-chan\". Also occurs when quoting mistakes swallow the intended channel expression.","commonSituations":"Users forgetting the channel variable after -chan; shell scripts dropping the last argument due to an empty variable expansion (e.g. `goroutines -chan $CH` with CH unset); copy-pasting partial commands from docs.","solutions":["Provide a channel expression after the flag: goroutines -chan myCh","If the channel name comes from a variable, ensure it is non-empty before building the command","Use `goroutines -help` (or `help goroutines`) to review valid flags: -chan, -exec, -group, etc."],"exampleFix":"// before\nargs := []string{\"goroutines\", \"-chan\"}\n\n// after\nargs := []string{\"goroutines\", \"-chan\", \"ch\"}","handlingStrategy":"validation","validationCode":"# shell: fail early when the channel arg is missing\nCH=${CH:?\"-chan requires a channel expression\"}\ndlv_ex_cmd=\"goroutines -chan $CH\"","typeGuard":"func hasValueAfter(args []string, flag string) bool {\n    for i, a := range args {\n        if a == flag {\n            return i+1 < len(args)\n        }\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always write the channel expression on the same command line: goroutines -chan ch","Quote channel expressions containing spaces","In scripts, use ${VAR:?msg} to abort on empty expansions","Run `help goroutines` to confirm flag syntax before composing complex commands"],"tags":["cli","parsing","goroutines"],"backgroundTag":"missing-flag-argument","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}