jsonforms
jsonforms copied to clipboard
Guranteed crash caused by findAllRefs and isObjectSchema for this autogenerated schema
Describe the bug
For the following schema, any input to the stickerPresets part of data would cause the form to crash.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"stickerPresets": {
"type": "array",
"items": {
"$ref": "#/definitions/StickerPreset"
}
},
"posterConfig": {
"$ref": "#/definitions/PosterConfig"
}
},
"required": ["stickerPresets", "posterConfig"],
"additionalProperties": false,
"definitions": {
"StickerPreset": {
"type": "object",
"properties": {
"groups": {
"type": "array",
"items": {
"$ref": "#/definitions/StickerGroup"
}
},
"onFace": {
"$ref": "#/definitions/Gltf"
}
},
"required": ["groups"],
"additionalProperties": false
},
"StickerGroup": {
"type": "object",
"properties": {
"stickers": {
"type": "array",
"items": {
"$ref": "#/definitions/Sticker"
}
},
"movable": {
"type": "boolean"
}
},
"required": ["stickers", "movable"],
"additionalProperties": false
},
"Sticker": {
"type": "object",
"properties": {
"widthRelativeToViewportWidth": {
"type": "number"
},
"position": {
"anyOf": [
{
"$ref": "#/definitions/BottomLeft"
},
{
"$ref": "#/definitions/TopLeft"
},
{
"$ref": "#/definitions/CenterCoordinate"
}
]
},
"source": {
"anyOf": [
{
"$ref": "#/definitions/Still"
},
{
"$ref": "#/definitions/Animated"
}
]
}
},
"required": ["widthRelativeToViewportWidth", "position", "source"],
"additionalProperties": false
},
"BottomLeft": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "bottomLeft"
}
},
"required": ["type"],
"additionalProperties": false
},
"TopLeft": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "topLeft"
}
},
"required": ["type"],
"additionalProperties": false
},
"CenterCoordinate": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "centerCoordinate"
},
"xRelativeToViewportWidth": {
"type": "number"
},
"yRelativeToViewportHeight": {
"type": "number"
}
},
"required": ["type", "xRelativeToViewportWidth", "yRelativeToViewportHeight"],
"additionalProperties": false
},
"Still": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "still"
},
"source": {
"type": "string"
}
},
"required": ["type", "source"],
"additionalProperties": false
},
"Animated": {
"type": "object",
"properties": {
"type": {
"type": "string",
"const": "animated"
},
"source": {
"type": "string"
},
"sprite": {
"$ref": "#/definitions/Sprite"
}
},
"required": ["type", "source", "sprite"],
"additionalProperties": false
},
"Sprite": {
"type": "object",
"properties": {
"frameRate": {
"type": "number"
},
"numRows": {
"type": "number"
},
"numCols": {
"type": "number"
},
"frameCount": {
"type": "number"
}
},
"required": ["frameRate", "numRows", "numCols"],
"additionalProperties": false
},
"Gltf": {
"type": "object",
"properties": {
"source": {
"type": "string"
},
"sprite": {
"$ref": "#/definitions/SpriteMaterial"
}
},
"required": ["source"],
"additionalProperties": false
},
"SpriteMaterial": {
"type": "object",
"properties": {
"meshName": {
"type": "string"
},
"sprite": {
"$ref": "#/definitions/Sprite"
}
},
"required": ["meshName", "sprite"],
"additionalProperties": false
},
"PosterConfig": {
"type": "object",
"properties": {
"headerSource": {
"type": "string"
},
"footerSource": {
"type": "string"
}
},
"required": ["footerSource"],
"additionalProperties": false
}
}
}
The following is the error message
OOPS! Something went wrong!
Cannot read properties of undefined (reading 'properties')
TypeError: Cannot read properties of undefined (reading 'properties')
at https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:982015
at t.findAllRefs (https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:982026)
at s (https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:982514)
at t.resolveSchema (https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:983167)
at https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:961714
at https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:962772
at Array.reduce (<anonymous>)
at https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:962740
at https://mirismaili.github.io/jsonforms-playground/dist/static/js/main.1d46151f.js:2:962772
at Array.reduce (<anonymous>)
Expected behavior
Not crashing
Steps to reproduce the issue
- Goto playground
- paste in the schema
- set ui schema to
{ "type": "Control", "scope": "#" } - set data to
{} - Click the add button to populate the "stickerPresets" array
Screenshots

In which browser are you experiencing the issue?
Google Chrome 105.0.5195.127
Framework
React
RendererSet
Material
Additional context
The schema is auto-generated from a ts type using ts-json-schema-generator. It seems that the error occurs at the ref parsing code whenever data changes. I also tried setting validationMode to "NoValidation", but the error still persists.