Details
-
Improvement
-
Resolution: Declined
-
Minor - P4
-
None
-
4.2.6
-
None
-
None
Description
When using JSON schema validation together with `validationAction: warn`, the warning messages are only logged on the mongo server logs.
The consuming application does not receive any logs through the driver logs. The `validationAction: warn` has no use for consuming apps, if they can't track the validation issues.
Steps to reproduce:
const { MongoClient, Logger } = require('mongodb'); |
|
|
(async () => {
|
Logger.setLevel('debug'); |
Logger.setCurrentLogger(msg => console.log(msg));
|
|
|
const client = await MongoClient.connect('mongodb://127.0.0.1:27017/?replSet=rs0'); |
const db = await client.db('testdb'); |
await db.command({
|
collMod: 'tests', |
validator: {
|
$jsonSchema: {
|
type: 'object', |
additionalProperties: false, |
properties: {
|
score: { type: 'number' } |
}
|
}
|
},
|
validationAction: 'warn' |
});
|
await db.collection('tests').insertOne({ bogus: true }); |
})();
|
Mongo server logs:
W STORAGE [conn10] Document would fail validation collection: testdb.tests doc: { _id: ObjectId('5f324fcbee2baed9ceccfd3a'), bogus: true }
|