[SERVER-28791] query failed: an empty object is not a valid value Created: 10/Apr/17  Updated: 27/Oct/23  Resolved: 17/Apr/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: Zhuoxiong Sun Assignee: Mark Agarunov
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

windows server 2012


Participants:

 Description   

It seems there is a issue in the latest mongo release 3.4.3. The code below was
working fine with Mongo version 3.2.9. But we run into the error with
3.4.3.

{aggregate([{ "$match" : { 
"dtHeader.Equipment_ID" : NumberLong(7), "dtHeader.SnapshotType" : "Snapshot", 
"dtHeader.RevolutionTimeStamp" : { "$gte" : 
ISODate("2017-04-09T07:48:54.351Z"), "$lte" : 
ISODate("2017-04-10T19:48:54.351Z") }, "dtHeader.RevolutionNumber" : { 
"$gte" : 1, "$lte" : 1 } } }, { "$project" : { "RevolutionTimeStamp" : 
"$dtHeader.RevolutionTimeStamp", "RevolutionNumber" : 
"$dtHeader.RevolutionNumber", "Historians" : { },
"Statistics" : { "29_2" : "$dtStatistics.29.2" }, "ComputationEquipment" : 
"$dtComputation_Equipment", "Annotations" : "$dtAnnotation", "ManualAnnotations" 
: "$dtAnnotation_Manual" } }])} 

Message = "Command aggregate failed: Invalid $project
specification: an empty object is not a valid value. Found empty object at path
Historians."



 Comments   
Comment by Mark Agarunov [ 17/Apr/17 ]

Hello charlie111,

Thank you for the report. The behavior you're seeing is due to a change made in 3.4. As per the documentation for the $project operator:

MongoDB 3.4 and later produces an error if the $project specification is an empty document.

Thanks,
Mark

Comment by Zhuoxiong Sun [ 10/Apr/17 ]

The stars outside "Historians" : { }, was not part of the code. It was to bold the text

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