Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-218

Incomplete documentation of reserved key words

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.0
    • Affects Version/s: 2.3
    • Component/s: Error Handling
    • Labels:
      None

      I was debugging an error in our application where we were able to write documents successfully, but reading them resulted in an error. The error message was simply: "false".

      I had to dig into the driver code to find that it was treating one of our fields as an internal error. Our document had a boolean called "err", which happened to be false in this case... Mongo thought it was a server error and used "false" as the exception message.

      com.mongodb.ServerError:

      static String getMsg( BSONObject o , String def )

      { Object e = o.get( "$err" ); if ( e == null ) e = o.get( "err" ); if ( e == null ) e = o.get( "errmsg" ); if ( e == null ) return def; return e.toString(); }

      This contradicts http://www.mongodb.org/display/DOCS/Legal+Key+Names, which only says that you can't start a key with '$' and can't use '.' in a key.

      From the same driver class, it looks like "code" is reserved too.

            Assignee:
            Unassigned Unassigned
            Reporter:
            permans Sam Perman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: