[SERVER-30700] Improve error message when $db is included in OP_QUERY commands Created: 16/Aug/17  Updated: 30/Oct/23  Resolved: 11/Sep/17

Status: Closed
Project: Core Server
Component/s: Logging
Affects Version/s: None
Fix Version/s: 3.5.13

Type: Improvement Priority: Minor - P4
Reporter: Hannes Magnusson Assignee: Mathias Stearn
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change
Sprint: Repl 2017-09-11
Participants:

 Description   

> db.runCommand({isMaster: 1, $db: "admin"})
{
	"ok" : 0,
	"errmsg" : "Parsed command object contains duplicate top level key: $db",
	"code" : 9,
	"codeName" : "FailedToParse"
}

There is no duplicate top level key $db, but I suspect the server is upgrading the OP_QUERY to OP_MSG and $db itself from the wire protocol



 Comments   
Comment by Ramon Fernandez Marina [ 11/Sep/17 ]

Author:

{'username': u'RedBeard0531', 'name': u'Mathias Stearn', 'email': u'mathias@10gen.com'}

Message:SERVER-30700 Better error message on $db in OP_QUERY request

Previously this would fail with a confusing error about a duplicate top-level
$db field.
Branch:master
https://github.com/mongodb/mongo/commit/83242faed10c8ce6bd78e20dcfd791408d84e51a

Comment by Hannes Magnusson [ 28/Aug/17 ]

I came across this when working on this in the driver, where I thought I was crafting a OP_MSG but I had a typo so it was OP_QUERY.

The error is correct, the message is just strange, and could use some improvement

Comment by Mathias Stearn [ 28/Aug/17 ]

bjori This is still an error since OP_QUERY messages shouldn't include a $db. I can make the error message more clear however.

Generated at Thu Feb 08 04:24:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.