{"record":{"id":"ce93cab04373159f","repo":"Tencent/WeKnora","slug":"create-opensearch-repository-w","errorCode":null,"errorMessage":"create opensearch repository: %w","messagePattern":"create opensearch repository: %w","errorType":"exception","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/container/engine_factory.go","lineNumber":154,"sourceCode":"// registration rather than on first query.\nfunc createOpenSearchEngine(\n\tctx context.Context, store types.VectorStore, auditSink openSearchRepo.AuditSink,\n) (interfaces.RetrieveEngineService, error) {\n\tclient, err := openSearchRepo.NewOpenSearchClient(&store.ConnectionConfig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create opensearch client: %w\", err)\n\t}\n\t// Env stores share the cluster without a per-store index prefix; DB stores\n\t// fold their (>=16-char) ID into the index name. NewRepository enforces the\n\t// length rule, so map env-store IDs to \"\".\n\tstoreID := store.ID\n\tif types.IsEnvStoreID(storeID) {\n\t\tstoreID = \"\"\n\t}\n\trepo, err := openSearchRepo.NewRepository(ctx, client, storeID, &store.IndexConfig,\n\t\topenSearchRepo.WithAuditSink(auditSink))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create opensearch repository: %w\", err)\n\t}\n\treturn retriever.NewKVHybridRetrieveEngine(repo, types.OpenSearchRetrieverEngineType), nil\n}\n\nfunc createPostgresEngine(store types.VectorStore, db *gorm.DB) (interfaces.RetrieveEngineService, error) {\n\tif store.ConnectionConfig.UseDefaultConnection {\n\t\trepo := postgresRepo.NewPostgresRetrieveEngineRepository(db)\n\t\treturn retriever.NewKVHybridRetrieveEngine(repo, types.PostgresRetrieverEngineType), nil\n\t}\n\t// Phase 1: only UseDefaultConnection is supported.\n\t// Custom connections require connection pool management and migration handling.\n\treturn nil, fmt.Errorf(\"custom postgres connections not yet supported; use use_default_connection=true\")\n}\n\nfunc createSQLiteEngine(_ types.VectorStore, db *gorm.DB) (interfaces.RetrieveEngineService, error) {\n\trepo := sqliteRetrieverRepo.NewSQLiteRetrieveEngineRepository(db)\n\treturn retriever.NewKVHybridRetrieveEngine(repo, types.SQLiteRetrieverEngineType), nil\n}","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/container/engine_factory.go#L136-L172","documentation":"createOpenSearchEngine wraps openSearchRepo.NewRepository failure — typically the cluster probe (version/k-NN plugin check) failing or an invalid index config/store ID length. Failing at registration prevents first-query surprises.","triggerScenarios":"Thrown at internal/container/engine_factory.go:154 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the OpenSearch cluster is reachable and has the k-NN plugin","Check the index config and store ID length rule","Retry registration once the cluster is healthy"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}