{"record":{"id":"ab4774695273a07d","repo":"grpc/grpc-go","slug":"s-v","errorCode":null,"errorMessage":"%s: %v","messagePattern":"%s: %v","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clientconn.go","lineNumber":232,"sourceCode":"\tif err := cc.initParsedTargetAndResolverBuilder(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tfor _, opt := range globalPerTargetDialOptions {\n\t\topt.DialOptionForTarget(cc.parsedTarget.URL).apply(&cc.dopts)\n\t}\n\n\tchainUnaryClientInterceptors(cc)\n\tchainStreamClientInterceptors(cc)\n\n\tif err := cc.validateTransportCredentials(); err != nil {\n\t\treturn nil, err\n\t}\n\n\tif cc.dopts.defaultServiceConfigRawJSON != nil {\n\t\tscpr := parseServiceConfig(*cc.dopts.defaultServiceConfigRawJSON, cc.dopts.maxCallAttempts)\n\t\tif scpr.Err != nil {\n\t\t\treturn nil, fmt.Errorf(\"%s: %v\", invalidDefaultServiceConfigErrPrefix, scpr.Err)\n\t\t}\n\t\tcc.dopts.defaultServiceConfig, _ = scpr.Config.(*ServiceConfig)\n\t}\n\tcc.keepaliveParams = cc.dopts.copts.KeepaliveParams\n\n\tif err = cc.initAuthority(); err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Register ClientConn with channelz. Note that this is only done after\n\t// channel creation cannot fail.\n\tcc.channelzRegistration(target)\n\tchannelz.Infof(logger, cc.channelz, \"parsed dial target is: %#v\", cc.parsedTarget)\n\tchannelz.Infof(logger, cc.channelz, \"Channel authority set to %q\", cc.authority)\n\n\tcc.csMgr = newConnectivityStateManager(cc.ctx, cc.channelz)\n\tcc.pickerWrapper = newPickerWrapper()\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/grpc/grpc-go/blob/03255a9237b6eb32710f6bc4f2de9a675b99fe36/clientconn.go#L214-L250","documentation":"During channel construction (clientconn.go:229-233), if a default service config was supplied via WithDefaultServiceConfig and parsing it fails, the parser error is wrapped with the prefix \"grpc: the provided default service config is invalid\". The channel aborts creation entirely.","triggerScenarios":"Passing malformed JSON to grpc.WithDefaultServiceConfig(\"...\"), or a structurally-valid but semantically invalid config (bad methodConfig, retry policy, or LB policy). NewClient / Dial returns this error before any connection attempt.","commonSituations":"Hand-edited default service config JSON with a syntax error; a config generated for a newer gRPC version with unsupported fields; invalid retry parameters or loadBalancingConfig.","solutions":["Validate the JSON string with a JSON parser and the gRPC service config schema before passing it to WithDefaultServiceConfig.","Read the wrapped error tail — it names the exact offending field (e.g. \"error: methodConfig[{...}]\") — and fix that field.","If migrating versions, regenerate the default config or drop unsupported keys."],"exampleFix":"// before\ngrpc.WithDefaultServiceConfig(`{\"methodConfig\":[{\"methodName\":[]}]}`)\n// after\ngrpc.WithDefaultServiceConfig(`{\"methodConfig\":[{\"name\":[{\"service\":\"pkg.Svc\",\"method\":\"Do\"}],\"retryPolicy\":{\"maxAttempts\":3}}]}`)","handlingStrategy":"validation","validationCode":"// Parse the default service config with the same parser before dialing.\nfunc validateDefaultCfg(js string) error {\n    jsPtr := js\n    scpr := parseServiceConfig(&jsPtr, 1) // or grpc.ParseServiceConfig(js) via public API\n    return scpr.Err\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run grpc.ParseServiceConfig(js) in a unit test against every default config you ship.","Lint service config JSON with a schema before deployment.","When upgrading gRPC, re-validate configs against the new parser's accepted fields."],"tags":["go","grpc","config","validation","clientconn"],"analyzedSha":"03255a9237b6eb32710f6bc4f2de9a675b99fe36","analyzedAt":"2026-08-07T00:29:34.215Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}