Operational Defect Database

BugZero found this defect 38 days ago.

MongoDB | 2638906

Missing 'let' variable incorrectly serialized as empty object

Last update date:

4/11/2024

Affected products:

MongoDB Server

Affected releases:

No affected releases provided.

Fixed releases:

8.0 Required

Description:

Info

Sharded $lookup that uses expressive (let-pipeline) syntax can incorrectly match missing local fields to empty object foreign fields. For example, given query: [ { $lookup: { from: coll_foreign.getName(), as: "res", let: {local_a: "$a"}, pipeline: [{$match: {$expr: {$eq: ["$$local_a", "$a"]},}}, {$project: {_id: 1}}] } } ], and documents {_id: 1, b: 1}, {_id: 2, a: {}} within both the local and foreign collection, we would expect to see the following documents in the result set: {_id: 1, b: 1, res: [{_id: 1}]}, {_id: 2, a: {}, res: [{_id: 2}]} Instead, we can see {_id: 1, b: 1, res: [{_id: 2}]}, {_id: 2, a: {}, res: [{_id: 2}]} Worth looking into whether this serialization error affects non-$lookup cases like those described in SERVER-57403

Top User Comments


Steps to Reproduce

Repro attached to linked BF as sharded_repro.js

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Open

Learn More

Search:

...