Skip to content

Conversation

@kmruiz
Copy link
Collaborator

@kmruiz kmruiz commented Oct 27, 2025

Proposed changes

Checklist

Copilot AI review requested due to automatic review settings October 27, 2025 15:33
@kmruiz kmruiz requested a review from a team as a code owner October 27, 2025 15:33
@kmruiz kmruiz requested a review from himanshusinghs October 27, 2025 15:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds validation to check that a vector search index exists before executing aggregate queries that use $vectorSearch, preventing errors from being thrown during query execution. This validation is controlled by the indexCheck configuration option.

Key Changes:

  • Added indexExists method to VectorSearchEmbeddingsManager to verify index existence
  • Modified AggregateTool to validate vector search indexes before executing aggregation pipelines
  • Added integration test to verify error handling when a non-existent vector search index is referenced

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/common/search/vectorSearchEmbeddingsManager.ts Added indexExists method to check if a vector search index exists in the database
src/tools/mongodb/read/aggregate.ts Added isVectorSearchIndexUsed method and index validation logic that throws an error when a non-existent vector search index is referenced
tests/integration/tools/mongodb/read/aggregate.test.ts Added test case to verify error handling for non-existent vector search indexes and enabled indexCheck in test configuration

@coveralls
Copy link
Collaborator

coveralls commented Oct 27, 2025

Pull Request Test Coverage Report for Build 18871399446

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 51 of 55 (92.73%) changed or added relevant lines in 2 files are covered.
  • 28 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.1%) to 80.225%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/common/search/vectorSearchEmbeddingsManager.ts 11 13 84.62%
src/tools/mongodb/read/aggregate.ts 40 42 95.24%
Files with Coverage Reduction New Missed Lines %
src/common/config.ts 14 89.7%
src/tools/tool.ts 14 78.64%
Totals Coverage Status
Change from base Build 18840683408: 0.1%
Covered Lines: 6355
Relevant Lines: 7781

💛 - Coveralls

Comment on lines 310 to 316
const indexExists = await this.session.vectorSearchEmbeddingsManager.indexExists({
database,
collection,
indexName,
});

return indexExists;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const indexExists = await this.session.vectorSearchEmbeddingsManager.indexExists({
database,
collection,
indexName,
});
return indexExists;
return await this.session.vectorSearchEmbeddingsManager.indexExists({
database,
collection,
indexName,
});

Copy link
Collaborator

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

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

I would expect we'd get an error from the server if we try to use $vectorSearch

@kmruiz
Copy link
Collaborator Author

kmruiz commented Oct 28, 2025

I would expect we'd get an error from the server if we try to use $vectorSearch

https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-stage/#fields

MongoDB Vector Search doesn't return results if you misspell the index name or if the specified index doesn't already exist on the cluster.

🥲

@kmruiz kmruiz enabled auto-merge (squash) October 28, 2025 10:15
@kmruiz kmruiz merged commit 833f3d2 into main Oct 28, 2025
18 checks passed
@kmruiz kmruiz deleted the chore/index-check-impr branch October 28, 2025 10:26
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.

5 participants