{"record":{"id":"58a44bc70195a43e","repo":"grpc/grpc-go","slug":"xds-failed-to-json-unmarshal-server-configuration-58a44b","errorCode":null,"errorMessage":"xds: failed to JSON unmarshal server configuration during bootstrap: %v, config:\n%s","messagePattern":"xds: failed to JSON unmarshal server configuration during bootstrap: (.+?), config:\n(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/bootstrap/bootstrap.go","lineNumber":352,"sourceCode":"\t\tServerURI:        sc.serverURI,\n\t\tChannelCreds:     sc.channelCreds,\n\t\tCallCredsConfigs: sc.callCredsConfigs,\n\t\tServerFeatures:   sc.serverFeatures,\n\t}\n\treturn json.Marshal(server)\n}\n\n// extraDialOptions captures custom dial options specified via\n// credentials.Bundle.\ntype extraDialOptions interface {\n\tDialOptions() []grpc.DialOption\n}\n\n// UnmarshalJSON takes the json data (a server) and unmarshals it to the struct.\nfunc (sc *ServerConfig) UnmarshalJSON(data []byte) error {\n\tserver := serverConfigJSON{}\n\tif err := json.Unmarshal(data, &server); err != nil {\n\t\treturn fmt.Errorf(\"xds: failed to JSON unmarshal server configuration during bootstrap: %v, config:\\n%s\", err, string(data))\n\t}\n\n\tsc.serverURI = server.ServerURI\n\tsc.channelCreds = server.ChannelCreds\n\tsc.callCredsConfigs = server.CallCredsConfigs\n\tsc.serverFeatures = server.ServerFeatures\n\n\tfor _, cc := range server.ChannelCreds {\n\t\t// We stop at the first credential type that we support.\n\t\tc := bootstrap.GetChannelCredentials(cc.Type)\n\t\tif c == nil {\n\t\t\tcontinue\n\t\t}\n\t\tbundle, cancel, err := c.Build(cc.Config)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to build credentials bundle from bootstrap for %q: %v\", cc.Type, err)\n\t\t}\n\t\tsc.selectedChannelCreds = cc","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/grpc/grpc-go/blob/0c51461d27177d997e14c642fe18c11668fc09a3/internal/xds/bootstrap/bootstrap.go#L334-L370","documentation":"Returned by ServerConfig.UnmarshalJSON when an individual server entry inside xds_servers fails to unmarshal into the serverConfigJSON struct (server_uri, channel_creds, call_creds, server_features). The raw server JSON is printed.","triggerScenarios":"Triggered at bootstrap.go:352 when json.Unmarshal(data, &server) fails for one element of the xds_servers array. Typically one field has an unexpected type, e.g. channel_creds is a string instead of an array of objects.","commonSituations":"channel_creds spelled wrong or set to a bare string; server_uri is a number; call_creds/server_features not arrays; whitespace or unicode issues inside one server block.","solutions":["Locate the failing server block using the printed JSON.","Confirm each field type matches the schema: server_uri string, channel_creds array of {type,config?}, call_creds array, server_features array of strings.","Validate with a JSON schema for the bootstrap (gRFC xDS bootstrap format).","Remove optional fields rather than leaving them as wrong-typed placeholders."],"exampleFix":"// before (channel_creds wrong type)\n{\"server_uri\":\"td:443\",\"channel_creds\":\"google_default\"}\n\n// after\n{\"server_uri\":\"td:443\",\"channel_creds\":[{\"type\":\"google_default\"}]}","handlingStrategy":"validation","validationCode":"// Validate a single server config object shape.\nfunc validateServerObject(raw json.RawMessage) error {\n    var s struct {\n        ServerURI    string            `json:\"server_uri\"`\n        ChannelCreds []json.RawMessage `json:\"channel_creds\"`\n    }\n    if err := json.Unmarshal(raw, &s); err != nil {\n        return fmt.Errorf(\"server object invalid: %w\", err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if _, err := bootstrap.NewConfigFromContents(data); err != nil {\n    return fmt.Errorf(\"bootstrap parse failed (check server blocks): %w\", err)\n}","preventionTips":["Match field names exactly: server_uri, channel_creds, call_creds, server_features.","Use arrays where the schema requires arrays.","Validate with a JSON schema for the bootstrap format."],"tags":["grpc","xds","bootstrap","config","json","go"],"backgroundTag":null,"analyzedSha":"0c51461d27177d997e14c642fe18c11668fc09a3","analyzedAt":"2026-08-11T14:49:15.055Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}