Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-14761

Investigate changes in SERVER-56207: Return JSON Schema `description` in document validation error message

      Downstream Change Summary

      If a document fails validation and JSON Schema is used in the validator, we will now include the "description" field as part of the error message. Users can now use "description" to include a human-friendly explanation of what the schema is intended to enforce.

      Flagging documentation changes as potentially needed in case some examples in the docs need updating with this change.

      Description of Linked Ticket

      It would be nice to return the description that the user included in the JSON schema, as it may help understand the business logic behind the rule in cases where there's a complex regex or some other non-obvious restrictions.

      Example:

      {
        "$jsonSchema": {
          "bsonType": "object",
          "properties": {
            "localization": {
              "bsonType": "object",
              "additionalProperties": false,
              "patternProperties": {
                "^description_(es|de|fr)+$": {
                  "bsonType": "string"
                }
              },
              "description": "Currently only Spanish, German and French are supported."
            }
          }
        }
      }

      Error:

      {
        "propertyName": "localization",
        "details": [
          {
            "operatorName": "additionalProperties",
            "specifiedAs": {
              "additionalProperties": false
            },
            "additionalProperties": ["description_cz"]
          }
        ]
      }
      

            Assignee:
            jeffrey.allen@mongodb.com Jeffrey Allen
            Reporter:
            backlog-server-pm Backlog - Core Eng Program Management Team
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              2 years, 30 weeks, 2 days ago