{"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":"critical","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/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/bootstrap/bootstrap.go#L382-L418","documentation":"Returned by ServerConfig.UnmarshalJSON (internal/xds/bootstrap/bootstrap.go:399) when, after JSON parsing, the `server_uri` field is empty. The server URI is the address of the xDS management server and is mandatory; an empty value makes the server config unusable.","triggerScenarios":"A server object in `xds_servers` omits `server_uri` (or sets it to \"\"), so after unmarshalling sc.serverURI is empty and the post-parse check fails.","commonSituations":"Hand-edited bootstrap file missing the field; templating that produced an empty URI; copy-paste that dropped server_uri when adapting an example.","solutions":["Add a non-empty `server_uri` to the offending server object (e.g. \"trafficdirector.googleapis.com:443\")","Re-check the bootstrap template/secret injection that populates the URI","Validate the bootstrap JSON for non-empty server_uri before use"],"exampleFix":"// before\n{\"channel_creds\":[{\"type\":\"insecure\"}]}\n// after\n{\"server_uri\":\"trafficdirector.googleapis.com:443\",\"channel_creds\":[{\"type\":\"google_default\"}]}","handlingStrategy":"validation","validationCode":"var probe struct {\n    XDSServers []struct{ ServerURI string `json:\"server_uri\"` } `json:\"xds_servers\"`\n}\n_ = json.Unmarshal(data, &probe)\nfor i, s := range probe.XDSServers {\n    if strings.TrimSpace(s.ServerURI) == \"\" {\n        return fmt.Errorf(\"xds_servers[%d] has empty server_uri\", i)\n    }\n}","typeGuard":null,"tryCatchPattern":"cfg, err := bootstrap.NewConfigFromContents(data)\nif err != nil {\n    log.Fatalf(\"xDS bootstrap invalid (check server_uri): %v\", err)\n}","preventionTips":["Template-bootstrap checks should fail closed on empty server_uri","Keep the URI in a single config variable to avoid drift"],"tags":["grpc","xds","bootstrap","config","go"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}