grpc/grpc-go · error
grpctransport: ServerURI is not set in ServerIdentifier
Error message
grpctransport: ServerURI is not set in ServerIdentifier
What it means
grpctransport.Builder.Build (grpc_transport.go:90-91) requires that ServerIdentifier.ServerURI is a non-empty string — it is the target the gRPC channel dials. An empty URI means there is no server to connect to, so Build fails immediately before any connection attempt.
Source
Thrown at internal/xds/clients/grpctransport/grpc_transport.go:91
}
// NewBuilder provides a builder for creating gRPC-based Transports using
// the credentials from provided map of credentials names to
// credentials.Bundle.
func NewBuilder(configs map[string]Config) *Builder {
return &Builder{
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()View on GitHub (pinned to 03255a9237)
Solutions
- Set ServerIdentifier.ServerURI to the xDS/LRS server address (e.g. dns:///xds-server:443) before calling Build.
- Validate that the config source providing the URI is populated.
- Add a precondition check in your code that ServerURI is non-empty before invoking Build.
Example fix
// before:
// si := clients.ServerIdentifier{}
// tr, err := builder.Build(si)
// after:
// si := clients.ServerIdentifier{ServerURI: "dns:///xds-server:443"}
// tr, err := builder.Build(si) Defensive patterns
Strategy: validation
Validate before calling
func validateServerIdentifier(si clients.ServerIdentifier) error {
if si.ServerURI == "" {
return errors.New("ServerIdentifier.ServerURI must be set")
}
return nil
} Prevention
- Centralize ServerIdentifier construction in a factory that enforces non-empty ServerURI.
- Read the URI from a validated config source.
When it happens
Trigger: Calling builder.Build(si) where si.ServerURI is empty — the ServerIdentifier was constructed without setting ServerURI, or a templating/config step left it blank.
Common situations: The ServerIdentifier was populated from a config map whose server_uri key was missing; the URI was read from an env var that was unset; a struct literal omitted the field by mistake.
Related errors
- grpctransport: Extensions is not set in ServerIdentifier
- xds: required field `xds_servers` not found in bootstrap con
- jwt_token_file is required in JWT call credentials config
- grpctransport: unknown config name %q specified in ServerIde
- grpctransport: config %q has nil credentials bundle
AI-assisted analysis of grpc/grpc-go@03255a9237 (2026-08-07).
Data as JSON: /api/errors/34249a342e6a46fc.
Report an issue: GitHub.