Add Qdrant vector database support#472
Conversation
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
|
I have read the Arakoo CLA Document and I hereby sign the CLA |
|
recheck |
625dd17 to
7960ad8
Compare
nightskat
left a comment
There was a problem hiding this comment.
Code Review:
🔴 [HIGH] Side-effect nguy hiểm từ dotenv trong thư viện
File: JS/edgechains/arakoodev/src/vector-db/src/lib/qdrant/qdrant.ts
import { config } from "dotenv";
config();Vấn đề:
Code này đang nằm trong package của một thư viện (@arakoodev/edgechains.js/vector-db). Việc gọi config() ngay ở top-level của thư viện là một anti-pattern. Nó sẽ tự động load .env từ thư mục làm việc hiện tại ngay khi module được import, có nguy cơ ghi đè hoặc xung đột với chiến lược quản lý biến môi trường của ứng dụng người dùng.
Gợi ý:
Xóa bỏ việc import và gọi dotenv. Hãy để ứng dụng cha tự chịu trách nhiệm load biến môi trường.
🔴 [HIGH] Logic Retry đang retry cả lỗi 4xx (Client Error)
File: JS/edgechains/arakoodev/src/vector-db/src/lib/qdrant/qdrant.ts
if (!response.ok) {
const message =
data?.status?.error ||
data?.message ||
response.statusText ||
"Unknown Qdrant error";
if (operation.retry(new Error(message))) return;
reject(new Error(`Qdrant request failed: ${message}`));
return;
}Vấn đề:
Bất kỳ khi nào API trả về mã lỗi (vd: 400 Bad Request nếu sai parameter, hoặc 401 Unauthorized), response.ok sẽ là false và thư viện sẽ thử lại (retry) tối đa 5 lần với exponential backoff. Việc retry các lỗi 4xx (lỗi từ phía người dùng) không những vô ích mà còn gây block và delay cực lớn cho request.
Gợi ý:
Chỉ nên retry đối với các lỗi mạng (Network Error), lỗi 429 Too Many Requests, và lỗi máy chủ 5xx. Reject ngay lập tức nếu là lỗi 4xx (trừ 429).
🟡 [MEDIUM] Khả năng throw Runtime Exception do thiếu validation URL
File: JS/edgechains/arakoodev/src/vector-db/src/lib/qdrant/qdrant.ts
this.QDRANT_URL = QDRANT_URL || process.env.QDRANT_URL!;Vấn đề:
Ký tự ! chỉ đánh lừa Type checker. Tại runtime, nếu không có giá trị nào, this.QDRANT_URL sẽ mang giá trị undefined. Khi các hàm bên dưới gọi this.QDRANT_URL.replace(...), ứng dụng sẽ crash do TypeError.
Gợi ý:
Validate URL và ném ra Exception có nghĩa ngay trong Constructor nếu nó không tồn tại.
Summary
@arakoodev/edgechains.js/vector-dbQdrantalongside the existing Supabase clientVerification
npm run buildnpx jest src/vector-db/src/tests/qdrant/qdrant.test.ts --runInBandNote: the full
npm test -- --runsuite currently fails on existing repo issues unrelated to this PR: Vitest runs Jest-style tests without Jest globals, two tests import missingdist/openaipaths, and scraper tests require network/credentials./claim #273