{"record":{"id":"c46d3aa3d2c17459","repo":"Tencent/WeKnora","slug":"create-milvus-client-w","errorCode":null,"errorMessage":"create milvus client: %w","messagePattern":"create milvus client: %w","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/container/engine_factory.go","lineNumber":255,"sourceCode":"\tclient, err := qdrant.NewClient(&qdrant.Config{\n\t\tHost:        cc.Host,\n\t\tPort:        port,\n\t\tAPIKey:      cc.APIKey,\n\t\tUseTLS:      cc.UseTLS,\n\t\tGrpcOptions: []grpc.DialOption{grpc.WithContextDialer(utils.SSRFSafeGRPCDialer)},\n\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create qdrant client: %w\", err)\n\t}\n\trepo := qdrantRepo.NewQdrantRetrieveEngineRepository(client, &store.IndexConfig)\n\treturn retriever.NewKVHybridRetrieveEngine(repo, types.QdrantRetrieverEngineType), nil\n}\n\nfunc createMilvusEngine(ctx context.Context, store types.VectorStore) (interfaces.RetrieveEngineService, error) {\n\tmilvusCfg := buildMilvusClientConfig(store.ConnectionConfig)\n\tclient, err := milvusclient.New(ctx, &milvusCfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create milvus client: %w\", err)\n\t}\n\trepo := milvusRepo.NewMilvusRetrieveEngineRepository(client, &store.IndexConfig)\n\treturn retriever.NewKVHybridRetrieveEngine(repo, types.MilvusRetrieverEngineType), nil\n}\n\nfunc buildMilvusClientConfig(cc types.ConnectionConfig) milvusclient.ClientConfig {\n\taddr := cc.Addr\n\tif addr == \"\" {\n\t\taddr = \"localhost:19530\"\n\t}\n\n\tmilvusCfg := milvusclient.ClientConfig{\n\t\tAddress: addr,\n\t\tDialOptions: []grpc.DialOption{\n\t\t\tgrpc.WithTimeout(5 * time.Second),\n\t\t\tgrpc.WithContextDialer(utils.SSRFSafeGRPCDialer),\n\t\t},\n\t}","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/container/engine_factory.go#L237-L273","documentation":"This wraps an error from milvusclient.New when building the Milvus client in createMilvusEngine. The config is derived via buildMilvusClientConfig from ConnectionConfig; New connects/validates the endpoint, so failures include bad addresses, missing credentials, or unreachable servers depending on the client version's laziness.","triggerScenarios":"createEngineServiceFromStore dispatching to a Milvus store where buildMilvusClientConfig produces an invalid endpoint (empty host, wrong port, bad URI scheme) or credentials/TLS settings rejected by milvusclient.New(ctx, &milvusCfg).","commonSituations":"Milvus running behind a proxy but configured with the internal gRPC port (19530) unreachable from the app; missing MILVUS_HOST env var; enabling TLS without a properly signed cert; using an address with http:// prefix where the client expects host:port.","solutions":["Log the output of buildMilvusClientConfig (redacted) and verify Host/Port/URI fields","Confirm the Milvus gRPC endpoint (default 19530) is reachable from the app's network","Strip scheme from host:port style addresses unless the client config expects a URI","Verify username/password or TLS settings match the deployed Milvus auth mode"],"exampleFix":"// before\ncc.Addr = \"http://milvus:19530\"\n// after\ncc.Addr = \"milvus:19530\"","handlingStrategy":"validation","validationCode":"func validMilvusAddr(cc types.ConnectionConfig) bool {\n    return cc.Addr != \"\" && !strings.Contains(cc.Addr, \" \")\n}\n// optionally probe: net.DialTimeout(\"tcp\", cc.Addr, 3*time.Second)","typeGuard":"func milvusReady(cc types.ConnectionConfig) bool { return cc.Addr != \"\" && net.ParseIP(strings.Split(cc.Addr, \":\")[0]) != nil || strings.Contains(cc.Addr, \".\") }","tryCatchPattern":"engine, err := createMilvusEngine(ctx, store)\nif err != nil {\n    if strings.Contains(err.Error(), \"create milvus client\") {\n        return fmt.Errorf(\"milvus client config bad (addr=%s redacted-creds): %w\", store.ConnectionConfig.Addr, err)\n    }\n    return err\n}","preventionTips":["Log buildMilvusClientConfig output (redacted) during startup to verify derived fields","Confirm network path to Milvus gRPC port 19530 from the deployment environment","Match TLS/auth settings to the Milvus deployment mode (standalone/cluster, auth on/off)","Pin milvus-client-go version; constructor behavior changed across versions"],"tags":["milvus","client-init","grpc","network"],"backgroundTag":"client-construction-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}