Details
-
Bug
-
Resolution: Works as Designed
-
Blocker - P1
-
None
-
None
-
None
-
OS: Windows 11
Python / Python Versions: Python 3.11.5
-
Not Needed
Description
Problem Statement/Rationale
In MongoDB Compass, I am encountering an issue with validation in a particular collection. When I define a validation rule, save it, and then update the collection, it consistently shows "Failed validation," even when the data matches the validation rule.
Example:
This is my original data under the collection
{
"_id": {
"$oid": "6513d54145b4ff5f40df58e3"
},
"name": "Mug"
}
I am validating as per this
{
name: {
type: 'string'
}
}
As the name is string but it shows me every validation under the Failed Validation.
Please be sure to attach relevant logs with any sensitive data redacted.
{"t":\{"$date":"2023-10-01T16:59:59.792+05:30"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn5","msg":"client metadata","attr":{"remote":"127.0.0.1:59272","client":"conn5","doc":{"application":
{"name":"MongoDB Compass"},"driver":{"name":"nodejs","version":"6.0.0"},"platform":"Node.js v18.16.1, LE","os":{"name":"win32","architecture":"x64","version":"10.0.22621","type":"Windows_NT"}}}}
{"t":\{"$date":"2023-10-01T16:59:59.797+05:30"},"s":"I", "c":"NETWORK", "id":6788700, "ctx":"conn5","msg":"Received first command on ingress connection since session start or auth handshake","attr":{"elapsedMillis":5}}
{"t":\{"$date":"2023-10-01T16:59:59.798+05:30"},"s":"I", "c":"COMMAND", "id":5324200, "ctx":"conn5","msg":"CMD: collMod","attr":{"cmdObj":{"collMod":"products","validator":{"name":{"type":"string"}},"validationLevel":"strict","validationAction":"error"}}}
{"t":\{"$date":"2023-10-01T16:59:59.800+05:30"},"s":"I", "c":"REPL", "id":7360104, "ctx":"conn5","msg":"Wrote oplog entry for collMod","attr":{"namespace":"aggregation_test.$cmd","uuid":{"uuid":{"$uuid":"e338876b-45e2-4e59-b53f-9c7bbbe1dcff"}},"opTime":{"ts":{"$timestamp":{"t":0,"i":0}},"t":-1},"object":{"collMod":"products","validator":{"name":{"type":"string"}},"validationLevel":"strict","validationAction":"error"}}}
Steps to Reproduce
How could an engineer replicate the issue you’re reporting?To reproduce the issue:
- Open MongoDB Compass.
- Select a collection.
- Define a validation rule, such as:
{
"name": { "type": "string" }}
- Save the validation rule.
- Update the collection.
Expected Results
What do you expect to happen?
- I expect the validation to pass as the "name" field is a string, and it should match the defined validation rule.
Actual Results
What do you observe is happening?
- Currently, the validation shows "Failed validation" even when the data complies with the validation rule.