coredns/coredns · error
unknown address type: %T
Error message
unknown address type: %T
What it means
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.
Source
Thrown at plugin/dnstap/msg/msg.go:51
switch a := addr.(type) {
case *net.TCPAddr:
t.SocketProtocol = &protoTCP
p := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)
t.QueryPort = &p
t.SocketFamily, t.QueryAddress = socketFamilyAndAddress(a.IP)
return nil
case *net.UDPAddr:
t.SocketProtocol = &protoUDP
p := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)
t.QueryPort = &p
t.SocketFamily, t.QueryAddress = socketFamilyAndAddress(a.IP)
return nil
default:
return fmt.Errorf("unknown address type: %T", a)
}
}
// SetResponseAddress the response address to the message. This also sets the SocketFamily and SocketProtocol.
func SetResponseAddress(t *tap.Message, addr net.Addr) error {
switch a := addr.(type) {
case *net.TCPAddr:
t.SocketProtocol = &protoTCP
p := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)
t.ResponsePort = &p
t.SocketFamily, t.ResponseAddress = socketFamilyAndAddress(a.IP)
return nil
case *net.UDPAddr:
t.SocketProtocol = &protoUDP
p := uint32(a.Port) // #nosec G115 -- Port is inherently bounded (1-65535)View on GitHub (pinned to 558c9757a9)
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.
Example fix
// before
msg.SetQueryAddress(t, myCustomAddr)
// after
tcpAddr, err := net.ResolveTCPAddr("tcp", myCustomAddr.String())
msg.SetQueryAddress(t, tcpAddr) Defensive patterns
Strategy: type-guard
Type guard
func isSupportedAddr(addr net.Addr) bool {
switch addr.(type) {
case *net.TCPAddr, *net.UDPAddr:
return true
}
return false
} Try / catch
if err := msg.SetQueryAddress(t, addr); err != nil {
log.Printf("dnstap: skipping query address: %v", err)
// continue without address instead of failing the tap message
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- connection rejected by Proxy Protocol connection policy
- PROXY Protocol header required but not present
- failed to list resource records for %v:%v:%v from gcp: %v
- failed to resolve %q: %v
- no addresses found for %q
AI-assisted analysis of coredns/coredns@558c9757a9 (2026-09-06).
Data as JSON: /api/errors/d90b0681df39d859.
Report an issue: GitHub.