{"record":{"id":"4d5c7a988a44564d","repo":"micro/go-micro","slug":"connect-reflected-grpc-target-s-w","errorCode":null,"errorMessage":"connect reflected grpc target %s: %w","messagePattern":"connect reflected grpc target (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gateway/mcp/grpcreflect.go","lineNumber":68,"sourceCode":"\t}\n\treturn nil\n}\n\nfunc (s *Server) reflectedGRPCTools(target ReflectedGRPCTarget) ([]*Tool, error) {\n\ttimeout := target.Timeout\n\tif timeout == 0 {\n\t\ttimeout = 10 * time.Second\n\t}\n\tctx, cancel := context.WithTimeout(s.opts.Context, timeout)\n\tdefer cancel()\n\n\tdialOpts := target.DialOptions\n\tif len(dialOpts) == 0 {\n\t\tdialOpts = []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}\n\t}\n\tconn, err := grpc.NewClient(target.Address, dialOpts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"connect reflected grpc target %s: %w\", target.Address, err)\n\t}\n\tdefer conn.Close()\n\n\tfiles, services, err := loadReflectedFiles(ctx, conn)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reflect grpc target %s: %w\", target.Address, err)\n\t}\n\n\tprefix := target.Name\n\tif prefix == \"\" {\n\t\tprefix = sanitizeToolPart(target.Address)\n\t}\n\n\tvar out []*Tool\n\tfor _, serviceName := range services {\n\t\tdesc, err := files.FindDescriptorByName(protoreflect.FullName(serviceName))\n\t\tif err != nil {\n\t\t\tcontinue","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/gateway/mcp/grpcreflect.go#L50-L86","documentation":"reflectedGRPCTools establishes a gRPC client connection to the configured reflection target using grpc.NewClient with the target's DialOptions (defaulting to insecure credentials). If client creation fails, the error is wrapped with the target address. This is the entry point for discovering tools via gRPC server reflection.","triggerScenarios":"Calling reflectedGRPCTools (via discoverReflectedGRPC) where target.DialOptions are invalid or grpc.NewClient rejects the target.Address/configuration.","commonSituations":"Malformed target address string (bad scheme/host); unsupported or conflicting grpc.DialOption combinations; attempting TLS credentials against a target that needs a different scheme (dns:/// vs passthrough).","solutions":["Check the wrapped (%w) grpc error; correct target.Address format (e.g. 'dns:///host:port' or 'host:port').","Review target.DialOptions for invalid or mutually conflicting options.","If the endpoint is plaintext, either leave DialOptions empty (defaults to insecure) or pass grpc.WithTransportCredentials(insecure.NewCredentials()) explicitly.","Upgrade/verify grpc-go version compatibility if NewClient (added in grpc-go 1.63) behaves differently than grpc.Dial in your setup."],"exampleFix":"// before\ntarget.DialOptions = []grpc.DialOption{grpc.WithTransportCredentials(credentials.NewTLS(nil))}\n// after\ntarget.DialOptions = nil // falls back to insecure default, or supply correctly configured TLS creds","handlingStrategy":"validation","validationCode":"if target.Address == \"\" || (!strings.Contains(target.Address, \":\") && !strings.Contains(target.Address, \"/\")) {\n    return fmt.Errorf(\"invalid grpc target address %q\", target.Address)\n}","typeGuard":"func validGRPCTarget(t GRPCTarget) bool {\n    return t.Address != \"\" && (len(t.DialOptions) == 0 || t.DialOptions != nil)\n}","tryCatchPattern":"conn, err := grpc.NewClient(target.Address, dialOpts...)\nif err != nil {\n    return fmt.Errorf(\"target %s rejected by grpc.NewClient: %w\", target.Address, err)\n}\ndefer conn.Close()","preventionTips":["Validate target.Address format before discovery.","Prefer leaving DialOptions empty to get the insecure default in dev.","Keep grpc-go >= 1.63 where grpc.NewClient is the supported dial API.","Confirm the target host:port is reachable before configuring it."],"tags":["grpc","reflection","connection","dial"],"backgroundTag":"grpc-client-connect-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}