Tencent/WeKnora · error

create weaviate client: %w

Error message

create weaviate client: %w

What it means

This wraps an error from weaviate.NewClient during createWeaviateEngine. The Weaviate Go client validates its configuration (scheme/host, auth config, headers) at construction time and returns an error for invalid input. Failures here happen before any HTTP request is made.

Source

Thrown at internal/container/engine_factory.go:317

	}

	weaviateCfg := weaviate.Config{
		Host:             host,
		ConnectionClient: utils.NewSSRFSafeHTTPClient(utils.DefaultSSRFSafeHTTPClientConfig()),
		GrpcConfig: &wgrpc.Config{
			Host: grpcAddress,
		},
		Scheme: scheme,
	}
	// Unlike the env path (which checks WEAVIATE_AUTH_ENABLED), the factory uses
	// APIKey directly — if a user provides it, they intend to use it.
	if cc.APIKey != "" {
		weaviateCfg.AuthConfig = auth.ApiKey{Value: cc.APIKey}
	}

	client, err := weaviate.NewClient(weaviateCfg)
	if err != nil {
		return nil, fmt.Errorf("create weaviate client: %w", err)
	}
	repo := weaviateRepo.NewWeaviateRetrieveEngineRepository(client, &store.IndexConfig)
	return retriever.NewKVHybridRetrieveEngine(repo, types.WeaviateRetrieverEngineType), nil
}

// createDorisEngine 创建 Apache Doris 检索引擎服务。
//
// Doris 同时使用两个端口:
//   - MySQL 协议(默认 9030)走 database/sql 做主链路读写;
//   - HTTP(默认 FE 8030)走 Stream Load 做 partial update。
//
// Addr 字段承担 host:9030 的 MySQL 端点;HTTPPort + Addr 的 host 部分组成 HTTP base URL。
func createDorisEngine(store types.VectorStore) (interfaces.RetrieveEngineService, error) {
	cc := store.ConnectionConfig
	if cc.Addr == "" {
		return nil, fmt.Errorf("doris connection requires addr (host:port)")
	}
	if cc.Database == "" {

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Ensure weaviateCfg.Host contains only host(:port) and the scheme is set separately via Scheme field
  2. Match the scheme to the deployment: https for TLS/TLS-terminated hosts, http for plaintext
  3. Trim whitespace/quotes from cc.APIKey before assigning auth.ApiKey
  4. Print the constructed weaviateCfg (redacted) to spot empty or malformed fields

Example fix

// before
weaviateCfg.Host = "https://weaviate.example.com"
// after
weaviateCfg.Scheme = "https"
weaviateCfg.Host = "weaviate.example.com"
Defensive patterns

Strategy: validation

Validate before calling

func validWeaviateConfig(cc types.ConnectionConfig) error {
    if cc.Host == "" { return errors.New("weaviate host is required") }
    if strings.Contains(cc.Host, "://") { return errors.New("weaviate host must not include scheme") }
    return nil
}

Type guard

func weaviateReady(cc types.ConnectionConfig) bool { return cc.Host != "" && !strings.Contains(cc.Host, "://") }

Try / catch

engine, err := createEngineServiceFromStore(ctx, store)
if err != nil && strings.Contains(err.Error(), "create weaviate client") {
    return fmt.Errorf("weaviate client config invalid: host must be host:port without scheme: %w", err)
}

Prevention

When it happens

Trigger: createEngineServiceFromStore dispatching to a Weaviate store with an invalid weaviateCfg: empty host, scheme/host mismatch (https host with http scheme), or a malformed auth.ApiKey value in cc.APIKey.

Common situations: Setting Host including the scheme ('https://weaviate.example.com') when the client expects host only; missing WEAVIATE_HOST env; wrong scheme for a TLS-terminated ingress; API key pasted with surrounding quotes.

Related errors


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