#9459·grpc-go

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

  1. Change clients.Node.Metadata from any to map[string]any.
  2. In internal.NodeProto, convert Node.Metadata using structpb.NewStruct(n.Metadata) and validate it during client initialization (New(cfg)) so invalid map entries return an immediate error instead of being silently dropped.
  3. Update internal/xds/xdsclient/clientimpl.go to pass node.GetMetadata().AsMap().

Alternatives Considered

  • Typing Node.Metadata as *structpb.Struct directly: couples the exported clients API surface to google.golang.org/protobuf/types/known/structpb.
  • Keeping Node.Metadata as any and supporting both map[string]any and *structpb.Struct in internal.NodeProto: leaves the field type untyped in the public API when map[string]any is sufficient.

Additional Context

Part of #9455.