grpc/grpc-go · error
grpctransport: Extensions field is %T, but must be %T in…
Error message
grpctransport: Extensions field is %T, but must be %T in ServerIdentifier
What it means
Returned by (*Builder).Build when si.Extensions is populated but is not of type grpctransport.ServerIdentifierExtension (grpc_transport.go:98). The Builder uses a type assertion to read ConfigName, so any other concrete type (including a pointer *ServerIdentifierExtension) is rejected.
Solutions
- Set Extensions to a value (not pointer): grpctransport.ServerIdentifierExtension{ConfigName: name}.
- Ensure only one transport package's extension type is in use across the codebase.
- The error message prints both the actual and expected types - read them to confirm the fix.
Example fix
// before
si.Extensions = &grpctransport.ServerIdentifierExtension{ConfigName: n}
// after
si.Extensions = grpctransport.ServerIdentifierExtension{ConfigName: n} Defensive patterns
Strategy: type-guard
Type guard
func isGRPCExtension(si clients.ServerIdentifier) bool {
_, ok := si.Extensions.(grpctransport.ServerIdentifierExtension)
return ok
} Try / catch
if _, ok := si.Extensions.(grpctransport.ServerIdentifierExtension); !ok {
// fix the assignment: use value type, not pointer
} Prevention
- Pass ServerIdentifierExtension by value, not by pointer.
- Add a helper that constructs the ServerIdentifier with the correct Extension type.
- Write a test that type-asserts Extensions on every identifier your code produces.
When it happens
Trigger: Setting si.Extensions to a *ServerIdentifierExtension (pointer) instead of the value type, or to an unrelated struct/int. The type assertion sce, ok := si.Extensions.(ServerIdentifierExtension) fails.
Common situations: Caller writes Extensions: &grpctransport.ServerIdentifierExtension{...} (pointer); mixing extensions from a different transport implementation; copy-paste from an example that used a pointer form.
Related errors
- grpctransport: config
- grpctransport: Extensions is not set in ServerIdentifier
- grpctransport: failed to create connection to server
- grpctransport: ServerURI is not set in ServerIdentifier
- grpctransport: unknown config name
AI-assisted analysis of grpc/grpc-go@0c51461d27 (2026-08-11).
Data as JSON: /api/errors/80e33bacef230204.
Report an issue: GitHub.
Appendix: source
Thrown at internal/xds/clients/grpctransport/grpc_transport.go:98
configs: configs,
connections: make(map[clients.ServerIdentifier]*grpc.ClientConn),
refs: make(map[clients.ServerIdentifier]int),
}
}
// Build returns a gRPC-based clients.Transport.
//
// The Extension field of the ServerIdentifier must be a ServerIdentifierExtension.
func (b *Builder) Build(si clients.ServerIdentifier) (clients.Transport, error) {
if si.ServerURI == "" {
return nil, fmt.Errorf("grpctransport: ServerURI is not set in ServerIdentifier")
}
if si.Extensions == nil {
return nil, fmt.Errorf("grpctransport: Extensions is not set in ServerIdentifier")
}
sce, ok := si.Extensions.(ServerIdentifierExtension)
if !ok {
return nil, fmt.Errorf("grpctransport: Extensions field is %T, but must be %T in ServerIdentifier", si.Extensions, ServerIdentifierExtension{})
}
config, ok := b.configs[sce.ConfigName]
if !ok {
return nil, fmt.Errorf("grpctransport: unknown config name %q specified in ServerIdentifierExtension", sce.ConfigName)
}
if config.Credentials == nil {
return nil, fmt.Errorf("grpctransport: config %q has nil credentials bundle", sce.ConfigName)
}
b.mu.Lock()
defer b.mu.Unlock()
if cc, ok := b.connections[si]; ok {
if logger.V(2) {
logger.Infof("Reusing existing connection to the server for ServerIdentifier: %v", si)
}
b.refs[si]++View on GitHub (pinned to 0c51461d27)