[SERVER-50243] validationAction: warn only logs warnings on mongo server logs Created: 11/Aug/20  Updated: 24/Aug/23  Resolved: 24/Aug/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.2.6
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Valentin Agachi Assignee: Dmitry Agranat
Resolution: Declined Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 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 }



 Comments   
Comment by Dmitry Agranat [ 18/Aug/20 ]

Hi avaly@plexapp.com,

After discussing this internally, there are currently no plans to implement this feature request. If this request becomes more popular by other users, we will certainly reconsider it.

Regards,
Dima

Comment by Valentin Agachi [ 13/Aug/20 ]

Our current workaround involves fetching the mongo server logs from Atlas API and inspecting those. Not very user-friendly. It would be easier to get those logs in the mongo driver logs.

Comment by Dmitry Agranat [ 12/Aug/20 ]

Hi avaly@plexapp.com, can't your application track the validation issues through mongod logs?

Generated at Thu Feb 08 05:22:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.