go-delve/delve · error

channel filter can not be negated

Error message

channel filter can not be negated

What it means

ListGoroutines with a GoroutineWaitingOnChannel filter rejects negated channel filters. Channel-wait filtering is implemented by evaluating a receive/send expression in the target's scope, so negation ('goroutines NOT waiting on channel X') cannot be computed and is explicitly refused.

Source

Thrown at service/rpc2/server.go:705

// be grouped with the specified criterion.
// If the value of arg.GroupBy is GoroutineLabel goroutines will
// be grouped by the value of the label with key GroupByKey.
// For each group a maximum of MaxGroupMembers example goroutines are
// returned, as well as the total number of goroutines in the group.
func (s *RPCServer) ListGoroutines(arg ListGoroutinesIn, out *ListGoroutinesOut) error {
	//TODO(aarzilli): if arg contains a running goroutines filter (not negated)
	// and start == 0 and count == 0 then we can optimize this by just looking
	// at threads directly.

	var gs []*proc.G
	var nextg int
	var err error
	var gsLoaded bool

	for _, filter := range arg.Filters {
		if filter.Kind == api.GoroutineWaitingOnChannel {
			if filter.Negated {
				return errors.New("channel filter can not be negated")
			}
			if arg.Count == 0 {
				return errors.New("count == 0 not allowed with a channel filter")
			}
			if arg.EvalScope == nil {
				return errors.New("channel filter without eval scope")
			}
			gs, err = s.debugger.ChanGoroutines(arg.EvalScope.GoroutineID, arg.EvalScope.Frame, arg.EvalScope.DeferredCall, filter.Arg, arg.Start, arg.Count)
			if len(gs) == arg.Count {
				nextg = arg.Start + len(gs)
			} else {
				nextg = -1
			}
			gsLoaded = true
			break
		}
	}

View on GitHub (pinned to a23773e6c3)

Solutions

  1. Set Negated=false on the channel filter.
  2. Express the inverse by fetching channel waiters and filtering on the client side.
  3. Use a different filter kind that supports negation.

Example fix

// before
filters := []api.ListGoroutinesFilter{{Kind: api.GoroutineWaitingOnChannel, Arg: chAddr, Negated: true}}
// after
filters := []api.ListGoroutinesFilter{{Kind: api.GoroutineWaitingOnChannel, Arg: chAddr, Negated: false}}
Defensive patterns

Strategy: validation

Validate before calling

for _, f := range filters {
    if f.Kind == api.GoroutineWaitingOnChannel && f.Negated {
        return errors.New("channel filters must not be negated")
    }
}

Try / catch

err := client.Call("RPCServer.ListGoroutines", in, &out)
if err != nil && strings.Contains(err.Error(), "can not be negated") {
    // rebuild filter with Negated=false and retry
}

Prevention

When it happens

Trigger: Sending a ListGoroutines RPC where arg.Filters contains {Kind: GoroutineWaitingOnChannel, Negated: true}.

Common situations: IDE or custom client building a goroutine filter UI that toggles a 'not' checkbox on a channel filter.

Related errors


AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31). Data as JSON: /api/errors/91e37555349650bf. Report an issue: GitHub.