[MDEV-30977] Additional key values are not validating properly when using unevaluatedProperties with properties declared in subschemas Created: 2023-03-31  Updated: 2023-11-27  Resolved: 2023-04-13

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 11.1
Fix Version/s: 11.1.0

Type: Bug Priority: Critical
Reporter: Ramesh Sivaraman Assignee: Rucha Deodhar
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-27128 Implement JSON Schema Validation FUNC... Closed

 Description   

The unevaluatedProperties object does not behave as expected when properties are declared in subschemas. Additional key values are not validating properly

SET @unevaluatedProperties_schema= '{
  "allOf": [
    {
      "type": "object",
      "properties": {
        "name": { "type": "string" }
      }
    }
  ],
  "properties": {
    "type": { "enum": ["residential", "business"] }
  },
  "required": ["type"],
  "unevaluatedProperties": false
}';

Actual result

11.0.2-opt>SELECT JSON_SCHEMA_VALID(@unevaluatedProperties_schema, '{"name": "joe", "type": "business", "dummy" : "hello" }');
+-------------------------------------------------------------------------------------------------------------+
| JSON_SCHEMA_VALID(@unevaluatedProperties_schema, '{"name": "joe", "type": "business", "dummy" : "hello" }') |
+-------------------------------------------------------------------------------------------------------------+
|                                                                                                           1 |
+-------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
 
11.0.2-opt>

Expected result

11.0.2-opt>SELECT JSON_SCHEMA_VALID(@unevaluatedProperties_schema, '{"name": "joe", "type": "business", "dummy" : "hello" }');
+-------------------------------------------------------------------------------------------------------------+
| JSON_SCHEMA_VALID(@unevaluatedProperties_schema, '{"name": "joe", "type": "business", "dummy" : "hello" }') |
+-------------------------------------------------------------------------------------------------------------+
|                                                                                                           0 |
+-------------------------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
 
11.0.2-opt>



 Comments   
Comment by Rucha Deodhar [ 2023-04-04 ]

Patch: https://github.com/MariaDB/server/tree/bb-MDEV-30977-json_schema

Comment by Alexey Botchkov [ 2023-04-09 ]

ok to push with a small comment.

Generated at Thu Feb 08 10:20:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.