Skip to content

Commit 8c60e19

Browse files
committed
fix: enhance payload validation to handle null or undefined cases in QdrantVectorStore
1 parent 6f87a73 commit 8c60e19

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,13 @@ export class QdrantVectorStore implements IVectorStore {
157157
* @param payload Payload to check
158158
* @returns Boolean indicating if the payload is valid
159159
*/
160-
private isPayloadValid(payload: Record<string, unknown>): payload is Payload {
161-
return "filePath" in payload && "codeChunk" in payload && "startLine" in payload && "endLine" in payload
160+
private isPayloadValid(payload: Record<string, unknown> | null | undefined): payload is Payload {
161+
if (!payload) {
162+
return false
163+
}
164+
const validKeys = ["filePath", "codeChunk", "startLine", "endLine"]
165+
const hasValidKeys = validKeys.every((key) => key in payload)
166+
return hasValidKeys
162167
}
163168

164169
/**
@@ -205,7 +210,7 @@ export class QdrantVectorStore implements IVectorStore {
205210
}
206211

207212
const operationResult = await this.client.query(this.collectionName, searchRequest)
208-
const filteredPoints = operationResult.points.filter((p) => this.isPayloadValid(p.payload!))
213+
const filteredPoints = operationResult.points.filter((p) => this.isPayloadValid(p.payload))
209214

210215
return filteredPoints as VectorStoreSearchResult[]
211216
} catch (error) {

0 commit comments

Comments
 (0)