False Alarm: Serious Bug in MongoDB Go Driver’s Geospatial distance calculation

Final Edit: False Alarm

It’s not MongoDB, It’s not the MongoDB Go driver, it’s something I did.
I was especially careful to double and triple check Long and Lat and still something went wrong.

Since reporting bugs in MongoDB is not longer possible for the average human, because you now have to be a MongoDB employee with an @mongodb.com email address and 2FA to even link your mongodb account with MongoDB’s JIRA, I’ll have to write this blog post.

I did try to contact customer service online but I’m not waiting around to help YOU on my time. Seriously WTF? If you don’t want bug reports don’t put up a “reporting bugs” page and make it virtually impossible to do. Just say “we don’t want bug reports from common plebs”.

Correction: You have a very short window where you can select if you’re an employee or customer/user when trying to sign in to MongoDB’s Jira. Since I was gathering information in other tabs I have missed that window and it redirected to the login for employees by default.

Correction2: It’s not MongoDB, it’s MongoDB’s Go driver.
But in my defense, if the sign in mechanism of MongoDB’s Jira wasn’t so bad this post wouldn’t be here to begin with but an issue on their Jira.

On to the bug. It started when I hit inconsistencies in the distance results vs the results of 2 other geospatial libraries. The 2 libraries are:


MongoDB uses the s2 lib (c++ version) as well. And from their GeoJSON documentation they require the ‘Point’ type to be in Longitude, Latitude order.

At first I didn’t know how to use the s2 lib so I asked the question on their repository on github:

And everything is explained there, but I’ll give you a summary.

In essence, as I already wrote, MongoDB requires the GeoJSON Point to be in Long, Lat order, but internally, since the very beginning MongoDB calculates the distance between 2 points in Lat, Long order. It uses Latitude for Longitude and Longitude for Latitude in their Point to Point distance calculation.

And since I can’t report the bug I have 2 options:
– do some manual indexing and querying
– not use MongoDB

I’m now stuck at a project I’ve been working on for the last 3 months that was close to being feature complete and now I have to switch technologies.
How come no one in 3 major version has noticed this before?
Has no one used the GeoJSON capabilities of MongoDB?
Or were they also not able to report this bug? Or maybe it was reported but ignored.


Move alone nothing to see here.

MongoDB Go Driver‘s Point to Point distance calculation is wrong because they confuse Longitude and Latitude internally – and there is no way to report bugs for people who are not mongodb employees or affiliates.

When doing the same $geoNear aggregation query in MongoDB Compass the results are correct.
But when using the official Go driver the results are incorrect.
However this also answers why no one stumbled upon this issue in 3 major versions. And I thought I had discovered America 😀