{"record":{"id":"0f8b1d6dad864a15","repo":"grpc/grpc-go","slug":"xds-failed-to-create-a-new-channel-for-server-con","errorCode":null,"errorMessage":"xds: failed to create a new channel for server config %v: %v","messagePattern":"xds: failed to create a new channel for server config (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/xds/clients/xdsclient/xdsclient.go","lineNumber":308,"sourceCode":"\tif err != nil {\n\t\treturn nil, func() {}, fmt.Errorf(\"xds: failed to create transport for server config %v: %v\", serverConfig, err)\n\t}\n\tstate := &channelState{\n\t\tparent:                c,\n\t\tserverConfig:          serverConfig,\n\t\tinterestedAuthorities: make(map[*authority]bool),\n\t}\n\tchannel, err := newXDSChannel(xdsChannelOpts{\n\t\ttransport:          tr,\n\t\tserverConfig:       serverConfig,\n\t\tclientConfig:       c.config,\n\t\teventHandler:       state,\n\t\tbackoff:            c.backoff,\n\t\twatchExpiryTimeout: c.watchExpiryTimeout,\n\t\tlogPrefix:          clientPrefix(c),\n\t})\n\tif err != nil {\n\t\treturn nil, func() {}, fmt.Errorf(\"xds: failed to create a new channel for server config %v: %v\", serverConfig, err)\n\t}\n\tstate.channel = channel\n\tc.xdsActiveChannels[*serverConfig] = state\n\tinitLocked(state)\n\treturn state.channel, c.releaseChannel(serverConfig, state, deInitLocked), nil\n}\n\n// releaseChannel is a function that is called when a reference to an xdsChannel\n// needs to be released. It handles closing channels with no active references.\n//\n// The function takes the following parameters:\n// - serverConfig: the server configuration for the xdsChannel\n// - state: the state of the xdsChannel\n// - deInitLocked: a function that performs any necessary cleanup for the xdsChannel\n//\n// The function returns another function that can be called to release the\n// reference to the xdsChannel. This returned function is idempotent, meaning\n// it can be called multiple times without any additional effect.","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/internal/xds/clients/xdsclient/xdsclient.go#L290-L326","documentation":"Returned when newXDSChannel returns an error inside getOrCreateChannel. newXDSChannel only fails if one of its required opts (transport, serverConfig, clientConfig, eventHandler) is nil — all of which are supplied internally by getOrCreateChannel, so in practice this indicates an internal invariant violation rather than a user config problem.","triggerScenarios":"Effectively unreachable through normal API use; would require nil serverConfig/clientConfig being passed into getOrCreateChannel, which the caller (getChannelForADS) guards against via the config construction path.","commonSituations":"Seen only with a malformed/nil Config (e.g. Servers or Authorities entries with nil pointers) passed to xdsclient.New, or a bug in custom code that calls getOrCreateChannel with nil fields.","solutions":["Ensure Config passed to xdsclient.New has non-nil Servers/Authorities with fully populated ServerConfig values.","If writing custom code that touches the channel layer, never pass nil transport/serverConfig/clientConfig/eventHandler.","Treat this as a bug to report upstream if hit through the public New/WatchResource API."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Ensure Config.Servers/Authorities entries are non-nil and populated.\nfunc validateConfigShape(cfg xdsclient.Config) error {\n    for _, s := range cfg.Servers { if s == nil { return errors.New(\"nil ServerConfig in Servers\") } }\n    for _, a := range cfg.Authorities {\n        if a == nil { return errors.New(\"nil Authority\") }\n        for _, s := range a.XDSServers { if s == nil { return errors.New(\"nil ServerConfig in Authority\") } }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always fully populate Config.Servers and Authorities before calling xdsclient.New.","Treat this error as an internal bug if reached through the public API.","Add a startup config validation pass in your bootstrap code."],"tags":["grpc","xds","internal","config"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}