Skip to content

CSHARP-5918: ExpressionNotSupportedException when a $set stage expression uses ToList method#1910

Open
sanych-sun wants to merge 1 commit intomongodb:mainfrom
sanych-sun:csharp5918
Open

CSHARP-5918: ExpressionNotSupportedException when a $set stage expression uses ToList method#1910
sanych-sun wants to merge 1 commit intomongodb:mainfrom
sanych-sun:csharp5918

Conversation

@sanych-sun
Copy link
Member

The problem was caused by the ToListMethodTranslater which used to ignore the serializerMap produced by the serializer finder and therefore used the wrong serializer.

@sanych-sun sanych-sun requested a review from a team as a code owner March 12, 2026 00:06
@sanych-sun sanych-sun added the bug Fixes issues or unintended behavior. label Mar 12, 2026
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

Fixes ExpressionNotSupportedException when a $set stage expression uses ToList() by replacing the manually constructed ListSerializer with the serializer obtained from the translation context (which respects the serializer map).

Changes:

  • Fixed ToListMethodToAggregationExpressionTranslator to use context.GetSerializer(expression) instead of manually creating a ListSerializer, ensuring the correct serializer is used
  • Added integration tests covering ToList() in $set pipeline updates, both same-model and cross-model scenarios

Reviewed changes

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

File Description
ToListMethodToAggregationExpressionTranslator.cs Use context-provided serializer instead of manually constructing one
CSharp5918.cs New integration tests for the fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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

Labels

bug Fixes issues or unintended behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants