{"record":{"id":"d90b0681df39d859","repo":"coredns/coredns","slug":"unknown-address-type-t","errorCode":null,"errorMessage":"unknown address type: %T","messagePattern":"unknown address type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/dnstap/msg/msg.go","lineNumber":51,"sourceCode":"\tswitch a := addr.(type) {\n\tcase *net.TCPAddr:\n\t\tt.SocketProtocol = &protoTCP\n\n\t\tp := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)\n\t\tt.QueryPort = &p\n\n\t\tt.SocketFamily, t.QueryAddress = socketFamilyAndAddress(a.IP)\n\t\treturn nil\n\tcase *net.UDPAddr:\n\t\tt.SocketProtocol = &protoUDP\n\n\t\tp := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)\n\t\tt.QueryPort = &p\n\n\t\tt.SocketFamily, t.QueryAddress = socketFamilyAndAddress(a.IP)\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown address type: %T\", a)\n\t}\n}\n\n// SetResponseAddress the response address to the message. This also sets the SocketFamily and SocketProtocol.\nfunc SetResponseAddress(t *tap.Message, addr net.Addr) error {\n\tswitch a := addr.(type) {\n\tcase *net.TCPAddr:\n\t\tt.SocketProtocol = &protoTCP\n\n\t\tp := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)\n\t\tt.ResponsePort = &p\n\n\t\tt.SocketFamily, t.ResponseAddress = socketFamilyAndAddress(a.IP)\n\t\treturn nil\n\tcase *net.UDPAddr:\n\t\tt.SocketProtocol = &protoUDP\n\n\t\tp := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/coredns/coredns/blob/558c9757a92b361e550bdba82d0b4ddf3d12d595/plugin/dnstap/msg/msg.go#L33-L69","documentation":"dnstap's msg.SetQueryAddress only understands net.Addr types it can handle (TCPAddr and UDPAddr). If the query address is some other concrete type, the default branch returns this error including the Go type name.","triggerScenarios":"Calling SetQueryAddress(t, addr) where addr's dynamic type is not *net.TCPAddr or *net.UDPAddr (e.g. a custom net.Addr implementation or nil-typed wrapper).","commonSituations":"Wrapping connections in custom net.Addr types in middleware, or passing an address derived from an unusual listener/socket type into the dnstap message builder.","solutions":["Convert the address to *net.TCPAddr or *net.UDPAddr (via net.ResolveTCPAddr/ResolveUDPAddr) before calling SetQueryAddress.","If a custom net.Addr is used, implement a conversion that extracts IP and port into a standard address type.","Check for nil or zero-value addr being passed where a real connection address is expected."],"exampleFix":"// before\nmsg.SetQueryAddress(t, myCustomAddr)\n// after\ntcpAddr, err := net.ResolveTCPAddr(\"tcp\", myCustomAddr.String())\nmsg.SetQueryAddress(t, tcpAddr)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isSupportedAddr(addr net.Addr) bool {\n    switch addr.(type) {\n    case *net.TCPAddr, *net.UDPAddr:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := msg.SetQueryAddress(t, addr); err != nil {\n    log.Printf(\"dnstap: skipping query address: %v\", err)\n    // continue without address instead of failing the tap message\n}","preventionTips":["Only pass addresses obtained from net.TCPConn/UDPConn (RemoteAddr/LocalAddr).","Convert custom net.Addr implementations to TCP/UDPAddr before dnstap encoding.","Never pass nil-typed or placeholder net.Addr values."],"tags":["dnstap","network","type-mismatch","net-addr"],"backgroundTag":"type-mismatch","analyzedSha":"558c9757a92b361e550bdba82d0b4ddf3d12d595","analyzedAt":"2026-09-06T22:47:02.106Z","contentChangedAt":"2026-09-06T22:47:02.106Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}