xds/clients: avoid using structs with interface/any fields as map keys
Author: dashpoleCreated Sep 30, 2026Updated Sep 30, 2026
What version of gRPC are you using?
master
What version of Go are you using (go version)?
go1.24
What operating system (Linux, Windows, …) and version?
Linux
What did you do?
In internal/xds/clients:
xdsclient.ResourceType(resource_type.go) containsDecoder Decoder(an interface) and is used as a map key by value inauthority.go(resources map[ResourceType]map[string]*resourceState) andads_stream.go(resourceTypeState map[ResourceType]*resourceTypeState).clients.ServerIdentifier(config.go) containsExtensions anyand is used as a map key by value ingrpctransport.Builder(connections map[clients.ServerIdentifier]*grpc.ClientConn) andxdsclient.go(xdsActiveChannels map[ServerConfig]*channelState).
If a consumer implements Decoder (or Extensions) as a value struct containing a slice, map, or function field, indexing those maps panics at runtime with runtime error: hash of unhashable type.
What did you expect to see?
xdsclient and grpctransport should not panic at runtime if a caller passes a Decoder implementation that is a non-comparable value type, and should avoid relying on ResourceType struct comparability.
What did you see instead?
ResourceType and ServerConfig/ServerIdentifier are used directly as map keys by value. Keying authority.resources and ads_stream.resourceTypeState by TypeURL string (or *ResourceType) eliminates this runtime panic hazard.
Part of #9455.
Source: grpc/grpc-go