{"record":{"id":"d25fc45ef626b5f5","repo":"slackhq/nebula","slug":"unexpected-packetconn-t-v-d25fc4","errorCode":null,"errorMessage":"Unexpected PacketConn: %T %#v","messagePattern":"Unexpected PacketConn: %T %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"udp/udp_generic.go","lineNumber":39,"sourceCode":")\n\ntype GenericConn struct {\n\t*net.UDPConn\n\tl *slog.Logger\n}\n\nvar _ Conn = &GenericConn{}\n\nfunc NewGenericListener(l *slog.Logger, s Settings) (Conn, error) {\n\tlc := NewListenConfig(s.Multi)\n\tpc, err := lc.ListenPacket(context.TODO(), \"udp\", s.Listen.String())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif uc, ok := pc.(*net.UDPConn); ok {\n\t\treturn &GenericConn{UDPConn: uc, l: l}, nil\n\t}\n\treturn nil, fmt.Errorf(\"Unexpected PacketConn: %T %#v\", pc, pc)\n}\n\nfunc (u *GenericConn) WriteTo(b []byte, addr netip.AddrPort) error {\n\t_, err := u.UDPConn.WriteToUDPAddrPort(b, addr)\n\treturn err\n}\n\nfunc (u *GenericConn) WriteBatch(bufs [][]byte, addrs []netip.AddrPort) (int, error) {\n\t// An un-sendable destination costs its own packet, never the ones behind it in the batch.\n\twritten := 0\n\tfor i, b := range bufs {\n\t\tif _, err := u.UDPConn.WriteToUDPAddrPort(b, addrs[i]); err == nil {\n\t\t\twritten++\n\t\t} else {\n\t\t\tu.l.Debug(\"failed to write packet in batch\", \"udpAddr\", addrs[i], \"error\", err)\n\t\t}\n\t}\n\treturn written, nil","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/udp/udp_generic.go#L21-L57","documentation":"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.","triggerScenarios":"Thrown at udp/udp_generic.go:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["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","Upgrade Go — a non-UDPConn result from ListenPacket for network \"udp\" indicates a Go runtime regression or a custom DialContext/Control wrapper in NewListenConfig","Verify no platform-specific code or build tags swap in an alternate PacketConn implementation","Report the %T/%#v values from the error in a nebula issue; they identify the unexpected concrete type"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}