Skip to content

fix: detect lost collection and return error instead of empty results on search#281

Merged
zc277584121 merged 1 commit intozilliztech:masterfrom
zc277584121:fix/detect-lost-collection-on-search
Mar 11, 2026
Merged

fix: detect lost collection and return error instead of empty results on search#281
zc277584121 merged 1 commit intozilliztech:masterfrom
zc277584121:fix/detect-lost-collection-on-search

Conversation

@zc277584121
Copy link
Collaborator

Summary

When a Milvus collection is deleted externally (e.g., cloud sync failure, manual cleanup) but the local snapshot still marks the codebase as indexed, search_code previously returned a misleading "No results found" message. Users couldn't distinguish between "no matching code" and "index data is gone".

This PR adds a collection existence check when search returns 0 results: if the local snapshot says "indexed" but the collection no longer exists in Milvus, it now returns an explicit error message telling the user to re-index with force=true.

Changes

  • packages/mcp/src/handlers.ts: Added 12 lines in handleSearchCode() to check hasCollection() when search returns empty results and local snapshot shows indexed status

Behavior

Scenario Before After
Collection exists, no matching results "No results found" "No results found" (unchanged)
Collection lost, local says indexed "No results found" (misleading) Error: "Index data has been lost... Please re-index with force=true"
Codebase still indexing, collection not yet created "No results found" + indexing note Same (unchanged, guarded by !isIndexing)

Test plan

  • E2E tested via Claude Code CLI + MCP: index codebase → search works → drop collection → search returns error with re-index instructions
  • Verified indexing-in-progress scenario is not affected
  • pnpm build:mcp succeeds

… on search

Signed-off-by: Cheney Zhang <chen.zhang@zilliz.com>
@zc277584121 zc277584121 merged commit 7255be0 into zilliztech:master Mar 11, 2026
4 checks passed
@zc277584121 zc277584121 deleted the fix/detect-lost-collection-on-search branch March 11, 2026 09:35
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.

1 participant