{"record":{"id":"c5291cdad65e4fdf","repo":"grpc/grpc-go","slug":"xds-server-uri-field-in-server-config-cannot-be","errorCode":null,"errorMessage":"xds: `server_uri` field in server config cannot be empty: %s","messagePattern":"xds: `server_uri` field in server config cannot be empty: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/bootstrap/bootstrap.go","lineNumber":400,"sourceCode":"\t\tfor _, cfg := range server.CallCredsConfigs {\n\t\t\tc := bootstrap.GetCallCredentials(cfg.Type)\n\t\t\tif c == nil {\n\t\t\t\t// Skip unsupported call credential types (don't fail bootstrap).\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tcallCreds, cancel, err := c.Build(cfg.Config)\n\t\t\tif err != nil {\n\t\t\t\t// Call credential validation failed - this should fail bootstrap.\n\t\t\t\treturn fmt.Errorf(\"failed to build call credentials from bootstrap for %q: %v\", cfg.Type, err)\n\t\t\t}\n\t\t\tsc.selectedCallCreds = append(sc.selectedCallCreds, callCreds)\n\t\t\tsc.extraDialOptions = append(sc.extraDialOptions, grpc.WithPerRPCCredentials(callCreds))\n\t\t\tsc.cleanups = append(sc.cleanups, cancel)\n\t\t}\n\t}\n\n\tif sc.serverURI == \"\" {\n\t\treturn fmt.Errorf(\"xds: `server_uri` field in server config cannot be empty: %s\", string(data))\n\t}\n\tif sc.credsDialOption == nil {\n\t\treturn fmt.Errorf(\"xds: `channel_creds` field in server config cannot be empty: %s\", string(data))\n\t}\n\treturn nil\n}\n\n// ServerConfigTestingOptions specifies options for creating a new ServerConfig\n// for testing purposes.\n//\n// # Testing-Only\ntype ServerConfigTestingOptions struct {\n\t// URI is the name of the server corresponding to this server config.\n\tURI string\n\t// ChannelCreds contains a list of channel credentials to use when talking\n\t// to this server. If unspecified, `insecure` credentials will be used.\n\tChannelCreds []ChannelCreds\n\t// CallCredsConfigs contains a list of call credentials to use for individual RPCs","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/bootstrap/bootstrap.go#L382-L418","documentation":"Returned by ServerConfig.UnmarshalJSON when, after parsing, server_uri is empty. server_uri is mandatory for every xDS server entry because it is the address the xDS client dials.","triggerScenarios":"Triggered at bootstrap.go:400 when a server object in xds_servers has no server_uri field or an empty string value.","commonSituations":"server_uri omitted entirely; field misspelled (e.g. 'serverUri' or 'uri'); value left as empty string when templating the bootstrap.","solutions":["Add a non-empty server_uri to the offending server object (e.g. 'trafficdirector.googleapis.com:443').","Check the field spelling: it must be snake_case server_uri.","If the bootstrap is generated, fix the generator/template."],"exampleFix":"// before\n{\"channel_creds\":[{\"type\":\"google_default\"}]}\n\n// after\n{\"server_uri\":\"trafficdirector.googleapis.com:443\",\"channel_creds\":[{\"type\":\"google_default\"}]}","handlingStrategy":"validation","validationCode":"// Reject server objects missing server_uri before writing the bootstrap file.\nfunc requireServerURI(servers []map[string]any) error {\n    for i, s := range servers {\n        uri, _ := s[\"server_uri\"].(string)\n        if uri == \"\" {\n            return fmt.Errorf(\"servers[%d]: server_uri is required\", i)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := bootstrap.NewConfigFromContents(data); err != nil {\n    if strings.Contains(err.Error(), \"server_uri\") {\n        // add/fix the server_uri field.\n    }\n}","preventionTips":["Always include server_uri in every server object.","Use snake_case field names.","Template the bootstrap from a single source of truth."],"tags":["grpc","xds","bootstrap","config","server-uri","go"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}