Skip to content

Commit ec16648

Browse files
committed
fix: enhance error handling for Qdrant initialization failures
1 parent 5b94f9e commit ec16648

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/services/code-index/vector-store/__tests__/qdrant-client.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import { vitest, describe, it, expect, beforeEach } from "vitest"
22
import { QdrantVectorStore } from "../qdrant-client"
33
import { QdrantClient } from "@qdrant/js-client-rest"
44
import { createHash } from "crypto"
5-
import * as path from "path"
65
import { getWorkspacePath } from "../../../../utils/path"
76
import { MAX_SEARCH_RESULTS, SEARCH_MIN_SCORE } from "../../constants"
8-
import { Payload, VectorStoreSearchResult } from "../../interfaces"
97

108
// Mocks
119
vitest.mock("@qdrant/js-client-rest")
@@ -229,7 +227,10 @@ describe("QdrantVectorStore", () => {
229227
mockQdrantClientInstance.createCollection.mockRejectedValue(createError)
230228
vitest.spyOn(console, "error").mockImplementation(() => {}) // Suppress console.error
231229

232-
await expect(vectorStore.initialize()).rejects.toThrow(createError)
230+
// The actual error message includes the URL and error details
231+
await expect(vectorStore.initialize()).rejects.toThrow(
232+
/Failed to connect to Qdrant vector database|vectorStore\.qdrantConnectionFailed/,
233+
)
233234

234235
expect(mockQdrantClientInstance.getCollection).toHaveBeenCalledTimes(1)
235236
expect(mockQdrantClientInstance.createCollection).toHaveBeenCalledTimes(1)
@@ -289,7 +290,10 @@ describe("QdrantVectorStore", () => {
289290
vitest.spyOn(console, "error").mockImplementation(() => {})
290291
vitest.spyOn(console, "warn").mockImplementation(() => {})
291292

292-
await expect(vectorStore.initialize()).rejects.toThrow(deleteError)
293+
// The actual error message includes the URL and error details
294+
await expect(vectorStore.initialize()).rejects.toThrow(
295+
/Failed to connect to Qdrant vector database|vectorStore\.qdrantConnectionFailed/,
296+
)
293297

294298
expect(mockQdrantClientInstance.getCollection).toHaveBeenCalledTimes(1)
295299
expect(mockQdrantClientInstance.deleteCollection).toHaveBeenCalledTimes(1)

0 commit comments

Comments
 (0)