3

I am trying to export my collections from Atlas to my Local MongoDB with MongoDB Compass tool. The issue is I can export some collections but my user collection returning error.

Error is: Path collision at tokens.0BUo4-zWowM9ldTIUbs57Q remaining portion 0BUo4-zWowM9ldTIUbs57Q

Any help appreciated, thanks.

MongoDB Compass version is 1.28.1

Baran Yeni
  • 314
  • 5
  • 14

3 Answers3

5

This error occurs because there are two different types. Probably you have your token set as an object, or as an empty string.

The solution to use Mongo Compass is manually unchecking the "Root level field" that marks as a string. Check the following example:

The error occurs because the field "Fotos_da_Ocorrência" can be an empty string "" or and object {bucketName: "", comment: "", elementId: ""}.

When i uncheck the Root Level Field it exports normally. Fields Example

Exported

Gustavo Garcia
  • 1,905
  • 1
  • 15
  • 27
2

By some search, I saw some other people facing similar problem. So it may be caused by some bug on MongoDB Compass version is 1.28.1. Workaround solution was using command line interface like below.

mongodump --uri="<connection-string>" --out /path/to/export
Baran Yeni
  • 314
  • 5
  • 14
  • "cannot unmarshal DNS message" – Oliver Dixon Jan 12 '22 at 17:05
  • Locate /etc/resolv.conf file and replace the nameserver with 8.8.8.8, and everything should work just fine. If that does not work , try 1.1.1.1. from: https://stackoverflow.com/a/60560041/14066260 – Baran Yeni Jan 12 '22 at 22:51
1

Gustavo is correct about the two types issue, but the solution depends on your use case and the data you're interested in.

In my case I have documents with a config field that can be either an object or null:

{ config: null }

{ config: { token: "abc123", date: "2023-05-24T08:25:19" }}

When I export in Compass and it asks me to select fields, I get 3 options:

  • config
  • config.token
  • config.date

By having the root field and the sub-fields selected, there is an overlap in the fields that are exported, hence the path collision issue. To resolve this, you can either deselect config or only select config.

If you deselect config (i.e. just select the sub-fields), then the output documents will only contain the config field if there is data for the sub-fields. In any documents where config is null, the config field is omitted.

If you only select config (i.e. deselect the sub-fields) then the output will contain the config field regardless of whether it is null or an object. It will still be omitted if it is undefined.

Toomy
  • 318
  • 2
  • 10