{"record":{"id":"35f99feec9cee5ac","repo":"slackhq/nebula","slug":"unknown-network-type-s","errorCode":null,"errorMessage":"unknown network type: %s","messagePattern":"unknown network type: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/service.go","lineNumber":199,"sourceCode":"\t\t\tAddr: tcpip.AddrFromSlice(addr.IP),\n\t\t\tPort: uint16(addr.Port),\n\t\t}\n\t\tnum := getProtocolNumber(addr.AddrPort().Addr())\n\t\treturn gonet.DialUDP(s.ipstack, nil, &fullAddr, num)\n\tcase \"tcp\", \"tcp4\", \"tcp6\":\n\t\taddr, err := net.ResolveTCPAddr(network, address)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tfullAddr := tcpip.FullAddress{\n\t\t\tNIC:  nicID,\n\t\t\tAddr: tcpip.AddrFromSlice(addr.IP),\n\t\t\tPort: uint16(addr.Port),\n\t\t}\n\t\tnum := getProtocolNumber(addr.AddrPort().Addr())\n\t\treturn gonet.DialContextTCP(ctx, s.ipstack, fullAddr, num)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown network type: %s\", network)\n\t}\n}\n\n// Dial dials the provided address\nfunc (s *Service) Dial(network, address string) (net.Conn, error) {\n\treturn s.DialContext(context.Background(), network, address)\n}\n\n// Listen listens on the provided address. Currently only TCP with wildcard\n// addresses are supported.\nfunc (s *Service) Listen(network, address string) (net.Listener, error) {\n\tif network != \"tcp\" && network != \"tcp4\" {\n\t\treturn nil, errors.New(\"only tcp is supported\")\n\t}\n\taddr, err := net.ResolveTCPAddr(network, address)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/service/service.go#L181-L217","documentation":"Service.DialContext only supports a fixed set of network types (e.g. \"tcp\", \"tcp4\", \"tcp6\") mapped via getProtocolNumber. Any other network string falls into the default branch and this error is thrown. It means the requested network parameter is not a protocol the in-memory netstack dialer can handle.","triggerScenarios":"Calling Service.Dial/DialContext with network values like \"udp\", \"unix\", \"ip\", \"tcp\" with typos, or empty string; the value reaches the switch's default case in DialContext (service/service.go:199).","commonSituations":"Passing user-supplied or config-driven network names straight into Dial; copying code from net.Dial examples using \"udp\" which this stack does not implement; typos like \"tcp4\" vs \"tcp\" mismatches when wiring gVisor netstack tests.","solutions":["Change the network argument to a supported TCP variant (\"tcp\", \"tcp4\", or \"tcp6\").","Validate/whitelist the network string before calling Dial and surface a clear error to your user.","If UDP support is needed, extend getProtocolNumber/DialContext in service.go to map the new protocol number instead of hitting default."],"exampleFix":"// before\nconn, err := svc.Dial(\"udp\", \"10.0.0.1:53\")\n// after\nconn, err := svc.Dial(\"tcp\", \"10.0.0.1:53\")","handlingStrategy":"validation","validationCode":"var allowed = map[string]bool{\"tcp\": true, \"tcp4\": true, \"tcp6\": true}\nif !allowed[network] {\n    return fmt.Errorf(\"unsupported network %q: use tcp, tcp4 or tcp6\", network)\n}\nconn, err := svc.Dial(network, address)","typeGuard":"func isSupportedNetwork(n string) bool {\n    switch n {\n    case \"tcp\", \"tcp4\", \"tcp6\":\n        return true\n    }\n    return false\n}","tryCatchPattern":"conn, err := svc.Dial(network, address)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"unknown network type\") {\n        return fmt.Errorf(\"network %q not supported by netstack dialer\", network)\n    }\n    return err\n}","preventionTips":["Whitelist network strings at your API boundary instead of passing user input through.","Check getProtocolNumber in service.go for the exact supported set before adding new call sites.","Add a unit test asserting each network value you use is dialable."],"tags":["network","gvisor","netstack","invalid-argument"],"backgroundTag":"unsupported-network-type","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"}