[JAVA-218] Incomplete documentation of reserved key words Created: 19/Nov/10 Updated: 31/Mar/15 Resolved: 12/Jul/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Error Handling |
| Affects Version/s: | 2.3 |
| Fix Version/s: | 3.0.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sam Perman | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
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. |
| Comments |
| Comment by Jeffrey Yemin [ 31/Mar/15 ] |
|
Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released. |
| Comment by Jeffrey Yemin [ 12/Jul/13 ] |
|
The driver no longer does this in the 3.0.x branch. It only looks for an error document if the query failure bit is set. See https://github.com/jyemin/mongo-java-driver/commit/fef95a7fc3ab939544e168e8f6b747b2d6602a57 |