#9463·grpc-go

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:

  1. xdsclient.ResourceType (resource_type.go) contains Decoder Decoder (an interface) and is used as a map key by value in authority.go (resources map[ResourceType]map[string]*resourceState) and ads_stream.go (resourceTypeState map[ResourceType]*resourceTypeState).
  2. clients.ServerIdentifier (config.go) contains Extensions any and is used as a map key by value in grpctransport.Builder (connections map[clients.ServerIdentifier]*grpc.ClientConn) and xdsclient.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.