[SERVER-6887] mongorestore silently ignores documents with invalid field names starting with $ Created: 29/Aug/12  Updated: 29/Aug/12  Resolved: 29/Aug/12

Status: Closed
Project: Core Server
Component/s: Tools
Affects Version/s: 2.0.7, 2.2.0-rc2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Stennie Steneker (Inactive) Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: mongorestore
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File test.bson    
Issue Links:
Depends
Duplicate
duplicates SERVER-2611 mongorestore and mongoimport should g... Closed
Related
is related to DOCS-455 mongorestore manpage improvements Closed
Operating System: ALL
Participants:

 Description   

In MongoDB 2.0.7 it is possible to update() a document and set an invalid field name starting with $:

> db.test.insert({_id: "foo"})
> db.test.update({_id: "foo"}, {$set: {$set: "bar"}})
> db.test.find({_id: "foo"})

If you mongodump and then mongorestore this database, documents with invalid field names are silently ignored (even with `mongorestore -vvvvv`).

In MongoDB 2.2.0rc2 the attempt to update() does throw an exception:

Modified field name may not start with $

.. but mongorestore still does not report any errors for skipped documents.



 Comments   
Comment by Stennie Steneker (Inactive) [ 29/Aug/12 ]

Though it wasn't clearly documented as such, the error handling behaviour for mongorestore is "fire & forget" by design so this request actually duplicates the feature request of SERVER-2611.

With verbose server logging an exception will be logged by mongod, eg:

Wed Aug 29 20:29:45 [conn3] User Assertion: 13511:document to insert can't have $ fields

A note has been added to the wiki page (http://www.mongodb.org/display/DOCS/Import+Export+Tools) and DOCS-455 added for the update of the information in the online manual.

Generated at Thu Feb 08 03:13:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.