Today I faced bson.errors.InvalidDocument on an insert_many() call. My function inserts up to 500 documents at once with only a few containing dots in key names, which I can't control. I don't want to recursively check every key name in 500 documents for it may contain a dot before inserting. The alternative is to react on the error when it occurs, but then it's still difficult to find the documents causing the error. Therefore I'd like to suggest passing the invalid document to the InvalidDocument error, so I can easily find and check only its keys rather then all the 500.
What do you think?