{"record":{"id":"21078791564aed9a","repo":"go-delve/delve","slug":"count-0-not-allowed-with-a-channel-filter","errorCode":null,"errorMessage":"count == 0 not allowed with a channel filter","messagePattern":"count == 0 not allowed with a channel filter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/rpc2/server.go","lineNumber":708,"sourceCode":"// For each group a maximum of MaxGroupMembers example goroutines are\n// returned, as well as the total number of goroutines in the group.\nfunc (s *RPCServer) ListGoroutines(arg ListGoroutinesIn, out *ListGoroutinesOut) error {\n\t//TODO(aarzilli): if arg contains a running goroutines filter (not negated)\n\t// and start == 0 and count == 0 then we can optimize this by just looking\n\t// at threads directly.\n\n\tvar gs []*proc.G\n\tvar nextg int\n\tvar err error\n\tvar gsLoaded bool\n\n\tfor _, filter := range arg.Filters {\n\t\tif filter.Kind == api.GoroutineWaitingOnChannel {\n\t\t\tif filter.Negated {\n\t\t\t\treturn errors.New(\"channel filter can not be negated\")\n\t\t\t}\n\t\t\tif arg.Count == 0 {\n\t\t\t\treturn errors.New(\"count == 0 not allowed with a channel filter\")\n\t\t\t}\n\t\t\tif arg.EvalScope == nil {\n\t\t\t\treturn errors.New(\"channel filter without eval scope\")\n\t\t\t}\n\t\t\tgs, err = s.debugger.ChanGoroutines(arg.EvalScope.GoroutineID, arg.EvalScope.Frame, arg.EvalScope.DeferredCall, filter.Arg, arg.Start, arg.Count)\n\t\t\tif len(gs) == arg.Count {\n\t\t\t\tnextg = arg.Start + len(gs)\n\t\t\t} else {\n\t\t\t\tnextg = -1\n\t\t\t}\n\t\t\tgsLoaded = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif !gsLoaded {\n\t\tgs, nextg, err = s.debugger.Goroutines(arg.Start, arg.Count)\n\t}","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/service/rpc2/server.go#L690-L726","documentation":"When a channel filter is present, ListGoroutines requires a non-zero Count because paging of channel waiters is computed against Count (len(gs) == arg.Count decides whether more pages exist). Count==0 would make the channel query meaningless, so it is rejected.","triggerScenarios":"ListGoroutines RPC with Filters containing Kind=GoroutineWaitingOnChannel and arg.Count == 0.","commonSituations":"Clients that omit Count (zero value by default) when listing goroutines, then add a channel-wait filter.","solutions":["Set Count to a positive value (e.g. page size or a large limit).","Default Count in the client when a channel filter is requested.","Drop the channel filter if unbounded listing is required (not supported)."],"exampleFix":"// before\nin := api.ListGoroutinesIn{Filters: channelFilters} // Count defaults to 0\n// after\nin := api.ListGoroutinesIn{Count: 100, Filters: channelFilters}","handlingStrategy":"validation","validationCode":"if hasChannelFilter(filters) && count <= 0 {\n    count = 100 // sensible default\n}","typeGuard":null,"tryCatchPattern":"err := client.Call(\"RPCServer.ListGoroutines\", in, &out)\nif err != nil && strings.Contains(err.Error(), \"count == 0\") {\n    in.Count = 100\n    err = client.Call(\"RPCServer.ListGoroutines\", in, &out)\n}","preventionTips":["Always set a positive Count when using filters.","Default Count in your client wrapper for ListGoroutines.","Remember channel filters page results via Start/Count."],"tags":["go","rpc","goroutines","paging","validation"],"backgroundTag":"invalid-pagination-parameter","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}