Andy E Andy E - 5 months ago 17
JSON Question

MongoDB FailedToParse: Bad characters in value

I have a simple mongodb database. I'm dumping using mongodump.

dump command

mongodump --db user_profiles --out /data/dumps/user-profiles


Here is the content of the user_profiles database. It has one collection (user_data) consisting of the following:

{ "_id" : ObjectId("555a882a722f2a009fc136e4"), "username" : "thor", "passwd" : "*1D28C7B35C0CD618178988146861D37C97883D37", "email" : "thor@avengers.com", "phone" : "4023331000" }
{ "_id" : ObjectId("555a882a722f2a009fc136e5"), "username" : "ironman", "passwd" : "*626AC8265C7D53693CB7478376CE1B4825DFF286", "email" : "tony@avengers.com", "phone" : "4023331001" }
{ "_id" : ObjectId("555a882a722f2a009fc136e6"), "username" : "hulk", "passwd" : "*CB375EA58EE918755D4EC717738DCA3494A3E668", "email" : "hulk@avengers.com", "phone" : "4023331002" }
{ "_id" : ObjectId("555a882a722f2a009fc136e7"), "username" : "captain_america", "passwd" : "*B43FA5F9280F393E7A8C57D20648E8E4DFE99BA0", "email" : "steve@avengers.com", "phone" : "4023331003" }
{ "_id" : ObjectId("555a882a722f2a009fc136e8"), "username" : "daredevil", "passwd" : "*B91567A0A3D304343624C30B306A4B893F4E4996", "email" : "daredevil@avengers.com", "phone" : "4023331004" }


After copying the dump to a nfs and then trying to load the dump into a test server using mongorestore

mongorestore --host db-test --port 27017 /remote/dumps/user-profiles


I'm getting the following error:

Mon May 18 20:19:23.918 going into namespace [user_profiles.user_data]
assertion: 16619 code FailedToParse: FailedToParse: Bad characters in value: offset:30


How to resolve this FailedToParse Error

Answer

To do further testing I created a test_db with a test_collection that only had one simple value 'x':1, and even that didn't work. So I knew something else had to be going on.

Versions of your tools matters

The version of mongodump that was being used was 3.0.3. The version on another virtual machine that was using mongorestore was 2.4.x. This was the cause for the errors. Once I got the mongodb-org-tools updated on my virtual machine (see official guide) I was able to get up and running as expected.

Hopefully this helps someone in the future. Check your versions!

mongodump --version
mongorestore --version
Comments