Mongorestore "error parsing metadata"

I do realize my lack of MongoDB knowledge/experience is most likely to blame here. Anyone that can point me to the right documentation would be appreciated.
MongoDB v4.4.8 community edition
mongorestore version: 100.5.0
Windows Server 2016
I am trying to restore a test DB from a bson dump but I don’t know the mongodump version used to create it. Here is the outcome,

C:\Users\eduardo>mongorestore /db:training D:\training
2021-08-31T08:48:45.126-0700 The --db and --collection flags are deprecated for this use-case; please use --nsInclude instead, i.e. with --nsInclude=${DATABASE}.${COLLECTION}
2021-08-31T08:48:45.127-0700 building a list of collections to restore from D:\training dir
2021-08-31T08:48:45.135-0700 reading metadata for training.table1 from D:\training\table1.metadata.json
2021-08-31T08:48:45.135-0700 Failed: restore error: error parsing metadata from D:\training\table1.metadata.json: error decoding key indexes.0: invalid JSON input. Position: 30. Character: N
2021-08-31T08:48:45.136-0700 0 document(s) restored successfully. 0 document(s) failed to restore.

The N in position 30 referenced in the message is for NumberInt(1).
{“options”:{},“indexes”:[{“v”:NumberInt(1) . . .

Could this be due to a version mismatch?

Hi @Eduardo_Carceller welcome to the community!

The N in position 30 referenced in the message is for NumberInt(1).
{“options”:{},“indexes”:[{“v”:NumberInt(1) . . .

Yes that is not a well-formed JSON. A quick check I did shows that "v": NumberInt(1) should be "v": {"$numberInt": 1} instead. NumberInt() implies that it’s a Javascript function call. Thus, the .json file extension is also not correct, since it’s not actually JSON in that file.

I checked multiple versions of mongodump, all the way to the version installed by MongoDB 4.0.0, and there the corresponding value is "v": 1 (no NumberInt nor $numberInt), so I’m not sure what tool created this backup.

I think the best way forward is to do a re-dump using the official tools, since there’s no telling what else is wrong with that dump.

Best regards
Kevin

Seems like a sound advice. Thanks a lot for taking the time to look into it. I’ll try to contact the person that gave me this dump.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.