...
Since updating to MongoDB Server v5.0.6. Community Version, $dateTrunc.date thinks any date is a string. For example: { $expr: { $lt: ["$paidDate", { $dateAdd: { startDate: { $dateTrunc: { date: new Date(), // <<======= unit: "day", binSize: 1, timezone: "Europe/London" } }, unit: "day", amount: 1, timezone: "Europe/London" } }] } } The above gives this error: PlanExecutor error during aggregation :: caused by :: $dateTrunc requires 'date' to be a date, but got string All existing queries via Compass and C++ are broken. If this is an official update to how this aggregate statement works, there is no updated documentation as far as I can see.
eric.sedor commented on Fri, 8 Apr 2022 15:41:00 +0000: Thanks for the update Adam! I'm not sure if or how that change may have affected the behavior you saw in your app. I'm going to close this ticket but we can reopen it if you notice the problem again outside of compass. Sincerely, Eric JIRAUSER1269340 commented on Wed, 6 Apr 2022 16:41:44 +0000: Thank you Eric, I have good news… Since Compass was updated yesterday to 1.31.1, this issue got resolved and the same pipeline (it's saved on my Compass) is working again. It's clearly related to this date/string issue I reported as well: https://jira.mongodb.org/browse/COMPASS-5664 But what I don't understand is how come it's now also working via C++ in my apps? Did Compass also update the driver on my computer? I know the server wasn't updated. eric.sedor commented on Wed, 6 Apr 2022 15:36:43 +0000: Hi adam@adamcrowe.net, I haven't been able to readily reproduce this error in MongoDB 5.0.6, but I might not have used the same aggregation pipeline stage; can you provide a complete operation that is failing in this way?
Click on a version to see all relevant bugs
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.