Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6822

Inconsistent error messages when database name is too long

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Cannot Reproduce
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Usability
    • Fully Compatible

    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.

      Attachments

        Activity

          People

            samantha.ritter@mongodb.com Samantha Ritter (Inactive)
            phedny Mark van Cuijk
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: