[SERVER-10891] Commands don't return "ok" field if targeting databases with invalid characters Created: 25/Sep/13  Updated: 26/Sep/13  Resolved: 25/Sep/13

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

Type: Bug Priority: Major - P3
Reporter: Stephen Lee Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to DOCS-2000 "Restrictions on Database Names" list... Closed
is related to JAVA-955 Space in Database Name Should Be Cons... Closed
is related to JAVA-956 Assume {ok:0} in case of missing 'ok'... Closed
Operating System: ALL
Steps To Reproduce:

See JAVA-955

Participants:

 Description   

I assume the server response should always include an 'ok' field.



 Comments   
Comment by A. Jesse Jiryu Davis [ 26/Sep/13 ]

Fair enough, PyMongo only forbids dot, dollar, slash, backslash, space, and null.

Comment by J Rassi [ 26/Sep/13 ]

jesse: I'm not convinced that pymongo performs the validation correctly. Does it allow database names containing characters *<>:|? when connecting to non-Windows servers, and forbid them when connecting to Windows servers? [1] I'm still convinced that drivers need to expect to receive either {$err: '...'} or {ok: 0} from the server in case of command failure.

[1] https://github.com/mongodb/mongo/blob/r2.5.2/src/mongo/db/namespace_string-inl.h#L48

Comment by Scott Hernandez (Inactive) [ 26/Sep/13 ]

The shell too, if we are keeping count

Comment by A. Jesse Jiryu Davis [ 26/Sep/13 ]

PyMongo validates the database name before sending to the server, seems to prevent triggering this server behavior.

Comment by Scott Hernandez (Inactive) [ 25/Sep/13 ]

This is a query error, and a client (driver) "fix".

Comment by J Rassi [ 25/Sep/13 ]

I think the fix for this issue should require driver changes only, not server changes.

mongod returns a document with {$err: "..."} to indicate failure of a query, and a document with {ok: 0} to indicate failure of a command. The command subsystem is only invoked when a query targets the collection "$cmd". However, the command subsystem is never being invoked here, since the driver is sending an OP_QUERY message with "test asdfasdf.$cmd" as the namespace (which fails namespace parsing, since it contains an invalid character). Thus mongod replies with a query failure message: { $err: "Invalid ns [test asdfasdf.$cmd]", code: 16256 }. I believe drivers need to correctly catch errors of this sort.

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