Skip to content

Conversation

@mabaasit
Copy link
Collaborator

Description

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@mabaasit mabaasit requested a review from a team as a code owner December 12, 2025 14:30
@mabaasit mabaasit requested review from Copilot and ivandevp December 12, 2025 14:30
@mabaasit mabaasit added feature flagged PRs labeled with this label will not be included in the release notes of the next release no release notes Fix or feature not for release notes labels Dec 12, 2025
@github-actions github-actions bot added the fix label Dec 12, 2025
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 modifies the generative AI query parsing logic to handle find and aggregate operations separately, ensuring each operation type receives only its relevant response fields.

Key Changes:

  • Modified parseXmlToJsonResponse to accept a type parameter ('find' or 'aggregate') to determine response structure
  • For 'aggregate' type, only the aggregation pipeline is returned; for 'find' type, both query and aggregation fields are returned
  • Updated all call sites to pass the appropriate type parameter

Reviewed changes

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

File Description
packages/compass-generative-ai/src/utils/parse-xml-response.ts Refactored to accept type parameter and conditionally return response fields based on operation type
packages/compass-generative-ai/src/utils/parse-xml-response.spec.ts Restructured tests into separate contexts for 'find' and 'aggregate' operations with updated expectations
packages/compass-generative-ai/src/atlas-ai-service.ts Updated call sites to pass the type parameter ('find' or 'aggregate') to parseXmlToJsonResponse
packages/compass-generative-ai/src/atlas-ai-service.spec.ts Added aggregation field to test expectation to match new response structure

limit: '10',
context('handles aggregate', function () {
const options = { logger: createNoopLogger(), type: 'aggregate' as const };
it('returns empty pipeline its not available in the response', function () {
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Corrected spelling: 'its' should be 'if it's' or 'when it's' for grammatical correctness.

Suggested change
it('returns empty pipeline its not available in the response', function () {
it("returns empty pipeline if it's not available in the response", function () {

Copilot uses AI. Check for mistakes.
: {}),
...(isQueryEmpty ? {} : { query }),
query,
aggregation,
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

For the 'find' type, returning both query and aggregation fields means aggregation will always be included even when not relevant to find operations. Consider if the find path should only return query-related fields to maintain a clearer separation between operation types, similar to how aggregate only returns aggregation.

Suggested change
aggregation,

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@ivandevp ivandevp left a comment

Choose a reason for hiding this comment

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

LGTM

@mabaasit mabaasit merged commit cd5bf6e into main Dec 15, 2025
83 of 84 checks passed
@mabaasit mabaasit deleted the fix-gen-ai-response branch December 15, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature flagged PRs labeled with this label will not be included in the release notes of the next release fix no release notes Fix or feature not for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants