It’s expected behavior, and the fact that you tried to remove oldName from the $groupBy (the field that contains null), the aggregation works fine. This confirms the behavior
Solution 1
Instead of leaving oldName as null, replace it with a recognizable placeholder value:
// When storing cars without an old name:
{ miles: 3, name: "Fiat", oldName: "N/A" }
{ miles: 5, name: "Opel", oldName: "N/A" }
After the groupBy replace it again to Null if you want
In addition to @junjiewu’s solution, the TS 2.5 includes a way to include null values in the aggregations by supplying either a default value or by allowing nulls to be the keys of the returned bucket.