Skip to content

Add Qdrant vector database support#472

Open
jchatelet wants to merge 1 commit into
arakoodev:tsfrom
jchatelet:jchatelet/qdrant-vector-db-support
Open

Add Qdrant vector database support#472
jchatelet wants to merge 1 commit into
arakoodev:tsfrom
jchatelet:jchatelet/qdrant-vector-db-support

Conversation

@jchatelet
Copy link
Copy Markdown

Summary

  • add a Qdrant REST client to @arakoodev/edgechains.js/vector-db
  • export Qdrant alongside the existing Supabase client
  • cover collection creation, vector upsert, search, point lookup, and delete-by-id
  • add focused Jest coverage and a README usage snippet

Verification

  • npm run build
  • npx jest src/vector-db/src/tests/qdrant/qdrant.test.ts --runInBand

Note: the full npm test -- --run suite currently fails on existing repo issues unrelated to this PR: Vitest runs Jest-style tests without Jest globals, two tests import missing dist/openai paths, and scraper tests require network/credentials.

/claim #273

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 10, 2026

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@jchatelet
Copy link
Copy Markdown
Author

I have read the Arakoo CLA Document and I hereby sign the CLA

@jchatelet
Copy link
Copy Markdown
Author

recheck

@jchatelet jchatelet force-pushed the jchatelet/qdrant-vector-db-support branch from 625dd17 to 7960ad8 Compare May 10, 2026 21:48
Copy link
Copy Markdown

@nightskat nightskat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants