Tencent/WeKnora · error

create qdrant client: %w

Error message

create qdrant client: %w

What it means

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.

Source

Thrown at internal/container/engine_factory.go:245

	return retriever.NewKVHybridRetrieveEngine(repo, types.ElasticsearchRetrieverEngineType), nil
}

func createQdrantEngine(store types.VectorStore) (interfaces.RetrieveEngineService, error) {
	cc := store.ConnectionConfig
	port := cc.Port
	if port == 0 {
		port = 6334
	}

	client, err := qdrant.NewClient(&qdrant.Config{
		Host:        cc.Host,
		Port:        port,
		APIKey:      cc.APIKey,
		UseTLS:      cc.UseTLS,
		GrpcOptions: []grpc.DialOption{grpc.WithContextDialer(utils.SSRFSafeGRPCDialer)},
	})
	if err != nil {
		return nil, fmt.Errorf("create qdrant client: %w", err)
	}
	repo := qdrantRepo.NewQdrantRetrieveEngineRepository(client, &store.IndexConfig)
	return retriever.NewKVHybridRetrieveEngine(repo, types.QdrantRetrieverEngineType), nil
}

func createMilvusEngine(ctx context.Context, store types.VectorStore) (interfaces.RetrieveEngineService, error) {
	milvusCfg := buildMilvusClientConfig(store.ConnectionConfig)
	client, err := milvusclient.New(ctx, &milvusCfg)
	if err != nil {
		return nil, fmt.Errorf("create milvus client: %w", err)
	}
	repo := milvusRepo.NewMilvusRetrieveEngineRepository(client, &store.IndexConfig)
	return retriever.NewKVHybridRetrieveEngine(repo, types.MilvusRetrieverEngineType), nil
}

func buildMilvusClientConfig(cc types.ConnectionConfig) milvusclient.ClientConfig {
	addr := cc.Addr
	if addr == "" {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify cc.Host is non-empty and resolves, and cc.Port is the Qdrant gRPC port (default 6334)
  2. Check that UseTLS matches the server's actual TLS configuration
  3. Ensure APIKey is set when the server requires one, and free of whitespace
  4. Print/log the resolved ConnectionConfig (redacting secrets) to spot empty or wrong values

Example fix

// before
cc.Port = 6333 // HTTP port, gRPC client fails
// after
cc.Port = 6334 // Qdrant gRPC port
Defensive patterns

Strategy: validation

Validate before calling

func validQdrantConfig(cc types.ConnectionConfig) error {
    if cc.Host == "" { return errors.New("qdrant host is required") }
    port, err := strconv.Atoi(cc.Port)
    if err != nil || port <= 0 || port > 65535 { return fmt.Errorf("qdrant port invalid: %q", cc.Port) }
    return nil
}

Type guard

func qdrantReady(cc types.ConnectionConfig) bool { return cc.Host != "" && func() bool { p, err := strconv.Atoi(cc.Port); return err == nil && p > 0 && p < 65536 }() }

Try / catch

engine, err := createEngineServiceFromStore(ctx, store)
if err != nil && strings.Contains(err.Error(), "create qdrant client") {
    return fmt.Errorf("qdrant config invalid: check host/port/grpc-port (6334) and TLS flag: %w", err)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/33d578f4007187f0. Report an issue: GitHub.