{"record":{"id":"33d578f4007187f0","repo":"Tencent/WeKnora","slug":"create-qdrant-client-w","errorCode":null,"errorMessage":"create qdrant client: %w","messagePattern":"create qdrant client: %w","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/container/engine_factory.go","lineNumber":245,"sourceCode":"\treturn retriever.NewKVHybridRetrieveEngine(repo, types.ElasticsearchRetrieverEngineType), nil\n}\n\nfunc createQdrantEngine(store types.VectorStore) (interfaces.RetrieveEngineService, error) {\n\tcc := store.ConnectionConfig\n\tport := cc.Port\n\tif port == 0 {\n\t\tport = 6334\n\t}\n\n\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 == \"\" {","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/container/engine_factory.go#L227-L263","documentation":"This wraps an error from the Qdrant Go client constructor in createQdrantEngine. The client is built with host, port, API key, TLS flag, and an SSRF-safe gRPC dialer; construction fails when the connection parameters are invalid. Note that grpc.Dial is lazy in older APIs, so failures here are usually configuration-level rather than network-level.","triggerScenarios":"createEngineServiceFromStore dispatching to a Qdrant store with an empty/invalid host, a non-numeric or out-of-range port, malformed API key, or incompatible TLS+host combination passed to the qdrant client config.","commonSituations":"Missing QDRANT_HOST/PORT env vars yielding empty strings; port set to an HTTP port (6333) instead of the gRPC port (6334); TLS enabled against a plaintext-only Qdrant instance; typo'd service DNS name.","solutions":["Verify cc.Host is non-empty and resolves, and cc.Port is the Qdrant gRPC port (default 6334)","Check that UseTLS matches the server's actual TLS configuration","Ensure APIKey is set when the server requires one, and free of whitespace","Print/log the resolved ConnectionConfig (redacting secrets) to spot empty or wrong values"],"exampleFix":"// before\ncc.Port = 6333 // HTTP port, gRPC client fails\n// after\ncc.Port = 6334 // Qdrant gRPC port","handlingStrategy":"validation","validationCode":"func validQdrantConfig(cc types.ConnectionConfig) error {\n    if cc.Host == \"\" { return errors.New(\"qdrant host is required\") }\n    port, err := strconv.Atoi(cc.Port)\n    if err != nil || port <= 0 || port > 65535 { return fmt.Errorf(\"qdrant port invalid: %q\", cc.Port) }\n    return nil\n}","typeGuard":"func qdrantReady(cc types.ConnectionConfig) bool { return cc.Host != \"\" && func() bool { p, err := strconv.Atoi(cc.Port); return err == nil && p > 0 && p < 65536 }() }","tryCatchPattern":"engine, err := createEngineServiceFromStore(ctx, store)\nif err != nil && strings.Contains(err.Error(), \"create qdrant client\") {\n    return fmt.Errorf(\"qdrant config invalid: check host/port/grpc-port (6334) and TLS flag: %w\", err)\n}","preventionTips":["Use the gRPC port (6334), not the HTTP port (6333), for Qdrant clients","Set UseTLS only when the server actually serves TLS","Fail fast at startup with a connectivity ping to Qdrant","Never leave Host/Port sourced from unset env vars without defaults or checks"],"tags":["qdrant","grpc","client-init","config"],"backgroundTag":"client-construction-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}