xds/clients: change clients.Node.Metadata from any to map[string]any
Author: dashpoleCreated Sep 30, 2026Updated Sep 30, 2026
Use case(s) - what problem will this feature solve?
In internal/xds/clients/config.go, Node.Metadata is typed as any (// Metadata is the xDS node metadata.) to avoid importing google.golang.org/protobuf/types/known/structpb in package clients (#8042).
However, internal.NodeProto (internal/xds/clients/internal/internal.go) only checks v, ok := n.Metadata.(*structpb.Struct) and silently returns nil for any other type. This forces callers to import structpb anyway, and causes map[string]any values passed by callers to be silently dropped with no error.
Proposed Solution
- Change
clients.Node.Metadatafromanytomap[string]any. - In
internal.NodeProto, convertNode.Metadatausingstructpb.NewStruct(n.Metadata)and validate it during client initialization (New(cfg)) so invalid map entries return an immediate error instead of being silently dropped. - Update
internal/xds/xdsclient/clientimpl.goto passnode.GetMetadata().AsMap().
Alternatives Considered
- Typing
Node.Metadataas*structpb.Structdirectly: couples the exportedclientsAPI surface togoogle.golang.org/protobuf/types/known/structpb. - Keeping
Node.Metadataasanyand supporting bothmap[string]anyand*structpb.Structininternal.NodeProto: leaves the field type untyped in the public API whenmap[string]anyis sufficient.
Additional Context
Part of #9455.
Source: grpc/grpc-go