[SERVER-6822] Inconsistent error messages when database name is too long Created: 22/Aug/12  Updated: 14/Apr/16  Resolved: 16/Mar/15

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

Type: Improvement Priority: Major - P3
Reporter: Mark van Cuijk Assignee: Samantha Ritter (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Participants:

 Description   

When trying to access a database with a name longer than allowed, error messages are inconsistent depending on the exact length of the database name.

A database name that is shorter than 64 characters is handled correctly.
A database name that is exactly 64 characters will return a 10032 message: db name too long
A database name that is longer than 64 characters will return a 13280 message: invalid db name

> use AVeryLongDatabaseNameThatIsAVeryLongDatabaseNameWithExact64Chars
switched to db AVeryLongDatabaseNameThatIsAVeryLongDatabaseNameWithExact64Chars
> show collections
Wed Aug 22 14:30:25 uncaught exception: error:

{ "$err" : "db name too long", "code" : 10032 }

> use AVeryLongDatabaseNameThatIsAVeryLongDatabaseNameWithEven1MoreChar
switched to db AVeryLongDatabaseNameThatIsAVeryLongDatabaseNameWithEven1MoreChar
> show collections
Wed Aug 22 14:31:59 uncaught exception: error: {
"$err" : "invalid db name: AVeryLongDatabaseNameThatIsAVeryLongDatabaseNameWithEven1MoreChar.system.namespaces",
"code" : 13280

Looking at the source code, it seems that the checks at /src/mongo/db/database.cpp:71 and /src/mongo/db/namespacestring.h:99 are inconsistent in handling database names of exactly 64 characters. I'd say the preferred message in both error cases is the 10032 (db name too long) message, since it's more descriptive.



 Comments   
Comment by Samantha Ritter (Inactive) [ 12/Aug/13 ]

I could not reproduce this bug in 2.5.2... as far as I can tell, for any name up to and including 64 characters, the operation goes through fine. For names longer than 64 characters, I get the following error:

Error: [AVeryLongDatabaseNameThatIsAVeryLongDatabaseNameWithEven1MoreChar] is not a valid database name at src/mongo/shell/mongo.js:40

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