[GODRIVER-2133] Aggregate should not accept bson.D as a pipeline Created: 17/Aug/21  Updated: 28/Oct/23  Resolved: 01/Sep/21

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.7.2

Type: Bug Priority: Major - P3
Reporter: Divjot Arora (Inactive) Assignee: Benji Rewis (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Not Needed

 Description   

Aggregate() functions currently accept bson.D as a valid value for the pipeline parameter but should not allow this because a bson.D is semantically a single document while a pipeline is an array of documents. This likely works internally because bson.D is implemented as a slice of bson.E, so it passes our "value is a slice" check in transformAggregatePipeline. We may have to special case bson.D and possibly other slice-based types like bson.Raw to prevent this. A reproducible example of this issue is here.



 Comments   
Comment by Githook User [ 01/Sep/21 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-2133 Error on nonempty semantic single documents as aggregate pipelines (#721)
Branch: release/1.7
https://github.com/mongodb/mongo-go-driver/commit/1e6b45648cb57c2441e168355255bceeaf9215a5

Comment by Githook User [ 01/Sep/21 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-2133 Error on nonempty semantic single documents as aggregate pipelines (#721)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/3a0c0a5787952438f1ca041f7b0cf64204ee187e

Comment by Benji Rewis (Inactive) [ 30/Aug/21 ]

To preserve the existing behavior, we've decided to throw a more informative client-side error when a non-empty bson.D, bsoncore.Document or bson.Raw is passed as the pipeline parameter. Because the empty versions of those types behave "as expected", we won't stop the user from using them.

PR: https://github.com/mongodb/mongo-go-driver/pull/721

Generated at Thu Feb 08 08:37:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.