slackhq/nebula · error

Unexpected PacketConn: %T %#v

Error message

Unexpected PacketConn: %T %#v

What it means

Type-guard failure at the end of NewGenericListener: ListenPacket on "udp" returned a PacketConn that is not a *net.UDPConn; its type and value are printed. Should be unreachable in practice — a defensive check against unexpected netpoll wrappers.

Source

Thrown at udp/udp_generic.go:39

)

type GenericConn struct {
	*net.UDPConn
	l *slog.Logger
}

var _ Conn = &GenericConn{}

func NewGenericListener(l *slog.Logger, s Settings) (Conn, error) {
	lc := NewListenConfig(s.Multi)
	pc, err := lc.ListenPacket(context.TODO(), "udp", s.Listen.String())
	if err != nil {
		return nil, err
	}
	if uc, ok := pc.(*net.UDPConn); ok {
		return &GenericConn{UDPConn: uc, l: l}, nil
	}
	return nil, fmt.Errorf("Unexpected PacketConn: %T %#v", pc, pc)
}

func (u *GenericConn) WriteTo(b []byte, addr netip.AddrPort) error {
	_, err := u.UDPConn.WriteToUDPAddrPort(b, addr)
	return err
}

func (u *GenericConn) WriteBatch(bufs [][]byte, addrs []netip.AddrPort) (int, error) {
	// An un-sendable destination costs its own packet, never the ones behind it in the batch.
	written := 0
	for i, b := range bufs {
		if _, err := u.UDPConn.WriteToUDPAddrPort(b, addrs[i]); err == nil {
			written++
		} else {
			u.l.Debug("failed to write packet in batch", "udpAddr", addrs[i], "error", err)
		}
	}
	return written, nil

View on GitHub (pinned to dd8f660c0a)

Solutions

  1. This is an impossible-by-design assertion: NewGenericListener type-asserts the PacketConn from lc.ListenPacket to *net.UDPConn; reaching the error means the runtime returned a different concrete type
  2. Upgrade Go — a non-UDPConn result from ListenPacket for network "udp" indicates a Go runtime regression or a custom DialContext/Control wrapper in NewListenConfig
  3. Verify no platform-specific code or build tags swap in an alternate PacketConn implementation
  4. Report the %T/%#v values from the error in a nebula issue; they identify the unexpected concrete type
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at udp/udp_generic.go:39 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03). Data as JSON: /api/errors/d25fc45ef626b5f5. Report an issue: GitHub.