{"record":{"id":"0e212524fca85ace","repo":"Tencent/WeKnora","slug":"create-weaviate-client-w","errorCode":null,"errorMessage":"create weaviate client: %w","messagePattern":"create weaviate client: %w","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/container/engine_factory.go","lineNumber":317,"sourceCode":"\t}\n\n\tweaviateCfg := weaviate.Config{\n\t\tHost:             host,\n\t\tConnectionClient: utils.NewSSRFSafeHTTPClient(utils.DefaultSSRFSafeHTTPClientConfig()),\n\t\tGrpcConfig: &wgrpc.Config{\n\t\t\tHost: grpcAddress,\n\t\t},\n\t\tScheme: scheme,\n\t}\n\t// Unlike the env path (which checks WEAVIATE_AUTH_ENABLED), the factory uses\n\t// APIKey directly — if a user provides it, they intend to use it.\n\tif cc.APIKey != \"\" {\n\t\tweaviateCfg.AuthConfig = auth.ApiKey{Value: cc.APIKey}\n\t}\n\n\tclient, err := weaviate.NewClient(weaviateCfg)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create weaviate client: %w\", err)\n\t}\n\trepo := weaviateRepo.NewWeaviateRetrieveEngineRepository(client, &store.IndexConfig)\n\treturn retriever.NewKVHybridRetrieveEngine(repo, types.WeaviateRetrieverEngineType), nil\n}\n\n// createDorisEngine 创建 Apache Doris 检索引擎服务。\n//\n// Doris 同时使用两个端口：\n//   - MySQL 协议（默认 9030）走 database/sql 做主链路读写；\n//   - HTTP（默认 FE 8030）走 Stream Load 做 partial update。\n//\n// Addr 字段承担 host:9030 的 MySQL 端点；HTTPPort + Addr 的 host 部分组成 HTTP base URL。\nfunc createDorisEngine(store types.VectorStore) (interfaces.RetrieveEngineService, error) {\n\tcc := store.ConnectionConfig\n\tif cc.Addr == \"\" {\n\t\treturn nil, fmt.Errorf(\"doris connection requires addr (host:port)\")\n\t}\n\tif cc.Database == \"\" {","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/container/engine_factory.go#L299-L335","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure weaviateCfg.Host contains only host(:port) and the scheme is set separately via Scheme field","Match the scheme to the deployment: https for TLS/TLS-terminated hosts, http for plaintext","Trim whitespace/quotes from cc.APIKey before assigning auth.ApiKey","Print the constructed weaviateCfg (redacted) to spot empty or malformed fields"],"exampleFix":"// before\nweaviateCfg.Host = \"https://weaviate.example.com\"\n// after\nweaviateCfg.Scheme = \"https\"\nweaviateCfg.Host = \"weaviate.example.com\"","handlingStrategy":"validation","validationCode":"func validWeaviateConfig(cc types.ConnectionConfig) error {\n    if cc.Host == \"\" { return errors.New(\"weaviate host is required\") }\n    if strings.Contains(cc.Host, \"://\") { return errors.New(\"weaviate host must not include scheme\") }\n    return nil\n}","typeGuard":"func weaviateReady(cc types.ConnectionConfig) bool { return cc.Host != \"\" && !strings.Contains(cc.Host, \"://\") }","tryCatchPattern":"engine, err := createEngineServiceFromStore(ctx, store)\nif err != nil && strings.Contains(err.Error(), \"create weaviate client\") {\n    return fmt.Errorf(\"weaviate client config invalid: host must be host:port without scheme: %w\", err)\n}","preventionTips":["Configure Host without the scheme and set Scheme separately","Trim quotes/whitespace from API keys loaded from env","Verify scheme matches the deployment's TLS setup before deploy","Run a startup self-check that constructs the client and issues a ready probe (v1/meta)"],"tags":["weaviate","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"}