-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.0.6
-
Component/s: None
-
None
Querying a collection for documents may raise a Mongo::Error::OperationFailure if the first document return contains an "errmsg" field.
From the code of the driver, I expect the same to be true of "err" and "$err".
Stacktrace:
Mongo::Error::OperationFailure: "whatever the content of 'errmsg' is."
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/operation/result.rb:214:in `validate!'
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/operation/read/query.rb:62:in `block in execute_message'
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/server/connection_pool.rb:99:in `with_connection'
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/server/context.rb:63:in `with_connection'
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/operation/read/query.rb:61:in `execute_message'
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/operation/read/query.rb:55:in `execute'
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/collection/view.rb:164:in `send_initial_query'
from /app/vendor/bundle/ruby/2.1.0/gems/mongo-2.0.6/lib/mongo/collection/view/iterable.rb:39:in `each'
Example document:
{ "errmsg": "whatever the content of 'errmsg' is." }
I think it would be prudent to also check for the presence of other fields to determine if this is really an OperationFailure (maybe adding an extra check for "ok" == 0, however, it's still not bulletproof.)