Skip to content

fix: add Milvus search result validation with actionable diagnostics#403

Open
afadhitya wants to merge 1 commit into
zilliztech:masterfrom
afadhitya:bugfix-milvus-search-result-validation
Open

fix: add Milvus search result validation with actionable diagnostics#403
afadhitya wants to merge 1 commit into
zilliztech:masterfrom
afadhitya:bugfix-milvus-search-result-validation

Conversation

@afadhitya

Copy link
Copy Markdown

Closes #393

Summary

Add VectorSearchResultValidationError and validateMilvusSearchResultRow() to guard against null Milvus search results that caused search_code to fail with "Cannot read properties of null (reading 'scores')" even after successful indexing.

Changes

Core package

  • search-result-validation.ts — new validation utility: VectorSearchResultValidationError error class + validateMilvusSearchResultRow() with actionable diagnostics
  • milvus-vectordb.ts — validate result rows in both regular and hybrid search before mapping scores
  • milvus-restful-vectordb.ts — same validation in RESTful client (both search + hybrid search)
  • context.ts — log embedding provider, expected dimension, and actual query dimension during search to surface mismatches early
  • vectordb/index.ts — export new validation symbols
  • Tests:
    • search-result-validation.test.ts — 3 tests (null row, missing score, valid)
    • milvus-vectordb.search-validation.test.ts — 2 tests (null result, null score)
    • context.search-dimensions.test.ts — 1 test (dimension logging)

MCP package

  • handlers.ts — catch VectorSearchResultValidationError and return actionable error message (dimension mismatch, collection mismatch, etc.) instead of generic "check if indexed"
  • Tests:
    • handlers.search-validation.test.ts — 1 test (actionable diagnostics)

Verification

  • All 34 core tests pass (9 suites)
  • All 6 MCP tests pass

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: search_code fails with "Cannot read properties of null (reading 'scores')" while index is completed

1 participant