Skip to content

egov-mdms-service (MDMS v2): schema validator throws ClassCastException on JSON-Schema oneOf unions #1675

Description

@ChakshuGautam

Summary

The MDMS v2 schema validator throws ClassCastException while walking schema definitions that use JSON-Schema oneOf with mixed primitive types (e.g. oneOf: [{type: number}, {type: array}, {type: null}]), both at /schema/v1/_create time and at data _create/_update validation time. oneOf is core JSON-Schema draft-07; polymorphic cell values are a natural shape for master data.

Reproduction

Register a schema whose property declares:

"slaHoursByState": {
  "type": "object",
  "additionalProperties": {
    "oneOf": [
      { "type": "number" },
      { "type": "array", "items": { "type": "number" }, "minItems": 2, "maxItems": 2 },
      { "type": "null" }
    ]
  }
}

Validation of data against it fails with an unhandled ClassCastException (e.g. org.json.JSONObject cannot be cast to ...) instead of evaluating the union.

Impact / workaround

Tenants are forced to flatten polymorphic shapes and lose declarative validation: we ship additionalProperties: true / items: {} and re-implement cell-shape + bounds validation application-side in two places (scheduler + configurator). Documented in the CCRS escalation design doc § "egov-mdms-v2 validator and oneOf" — egovernments/Citizen-Complaint-Resolution-System#770, discussion egovernments/Citizen-Complaint-Resolution-System#773 (prompt 8).

Related quirk worth fixing in the same pass: an empty x-unique also trips a ClassCastException, which is why singleton schemas in the wild carry a placeholder singletonKey field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions