-
Notifications
You must be signed in to change notification settings - Fork 155
chore: adds validation for vector search stage's pre-filter expression MCP-242 #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
080d840 to
e77cf2e
Compare
There was a problem hiding this 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 ensure that fields used in $vectorSearch pre-filter MQL expressions are properly indexed in the vector search index. When validation fails, the tool call is rejected with a MongoDBError.
Key Changes:
- Adds a helper function to extract field names from vector search filter expressions
- Implements validation logic in the aggregate tool to check filter fields against the vector search index definition
- Adds comprehensive test coverage for the new validation behavior
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/helpers/collectFieldsFromVectorSearchFilter.test.ts | New unit tests for the filter field extraction helper |
| tests/integration/tools/mongodb/read/aggregate.test.ts | Integration tests validating filter field validation behavior |
| src/tools/mongodb/read/aggregate.ts | Implements validation logic and index field retrieval |
| src/helpers/collectFieldsFromVectorSearchFilter.ts | Helper to recursively extract field names from MQL filter expressions |
| src/common/logger.ts | Adds new log ID for validation errors |
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Pull Request Test Coverage Report for Build 18978749862Details
💛 - Coveralls |
|
Changes LGTM, added a small refactor to put the assertion helper independent of the class since the tool class was getting quite huge. We might want this for others helpers we have to. |
Proposed changes
This PR adds an assertion to validate that if a vector search stage asks for a pre-filter using MQL expression then the fields in the MQL expression are indeed indexed as part of vector search index.
When validation is not met, we fail the tool call with
MongoDBError.Checklist