[SERVER-32705] Json schema does not correctly validate an array of enums Created: 15/Jan/18 Updated: 31/Jan/18 Resolved: 16/Jan/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Eric Tray | Assignee: | Kyle Suarez |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Operating System: | ALL | |||||||||||||||
| Steps To Reproduce: | Given the following Json schema valiator applied to a collection:
I am still able to insert and also update a document with a 'values' property that contains an invalid value not included in the enum. For example if I insert or update a document via $set containing values ["one", "two", "three", "four"] it still passes validation. |
|||||||||||||||
| Participants: |
| Description |
|
Using a Json schema containing a property with an enum keyword nested inside a items keyword should fail validation on encountering a value not included in the enum array. Currently it passes validation with invalid values included. |
| Comments |
| Comment by Kyle Suarez [ 16/Jan/18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hey etay2000, Glad things are working as expected. If you run into a problem in the future, don't hesitate to post in the user group! Best, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Eric Tray [ 16/Jan/18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Kyle, Sure enough I can't reproduce this anymore either. I swear I have been messing with this off and on for a few days and was debating whether or not to post it to the user groups first or file it as a bug. I was using the Java client and loading an external .json file, parsing it into a Document, then passing that Document into Filters#jsonSchema. Now I am even more confused because the only change I made to my external .json file after testing your example was to remove a top level "bsonType" : "object" keyword that I had before the properties keyword. After I removed that keyword and tested it worked as expected. However, I then put the 'bsonType' keyword back in and tested it again and it still worked as expected. You can close this issue and chalk it up to user error, even though I still don't know what exactly that error was. Thanks, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kyle Suarez [ 16/Jan/18 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi etay2000, I can't reproduce a bug. This is what I've tried:
This script asserts that both an insert and an update with a bad array will fail. Could you please verify that the schema that you've used is correct? If you are still experiencing a bug, please let me know what MongoDB version you're using. Regards, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||