maximum call stack exceed with 'max_depth=3'
General information
- json-editor version: It's working with 2.6.1. Since 2.7.0 not working anymore
Expected behavior
All items will be rendered correct
Actual behavior
Page stops working with error in Log
Steps to reproduce the behavior
I'm not able to create a direct link example because the website starts crashing but here is the schema with the js calls to watch some fields.
As said, with version 2.6.1 everything is working without any adjustment.
With 2.7 as well as 2.8 the form will only be generated when i set max_depth to a value lower then 3. After that everything starts to crash.
Do i may have a error in the watchers which results in a infinitive loop or something like that?
var schema = {
"title": " ",
"type": "object",
"options": {
"disable_collapse": true,
},
"definitions": {
"ruleBase": {
"title": "ruleBase",
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"disable_collapse": true,
"properties": {
"name": {
"propertyOrder": 1,
"required": true,
"title": "Name",
"type": "string",
"options": {
"grid_columns": 6,
}
},
"description": {
"propertyOrder": 2,
"required": true,
"title": "Description",
"type": "string",
"options": {
"grid_columns": 5
}
},
"enabled": {
"propertyOrder": 3,
"title": "Enabled",
"type": "boolean",
"format": "checkbox",
"options": {
"grid_columns": 1
}
}
}
},
"groupBase": {
"title": "groupBase",
"type": "object",
"format": "grid",
"additionalProperties": false,
"disable_edit_json": true,
"collapsed": true,
"properties": {
"name": {
"propertyOrder": 1,
"required": true,
"title": "Name",
"type": "string",
"options": {
"grid_columns": 6
}
},
"description": {
"propertyOrder": 2,
"required": true,
"title": "Description",
"type": "string",
"options": {
"grid_columns": 6
}
}
}
},
"generic": {
"title": "Generic Allow Rule",
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"collapsed": true,
"options": {
"disable_collapse": true
},
"allOf": [
{
"$ref": "#/definitions/ruleBase"
}
],
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["any"],
"default": "any",
"options": {
"hidden": true
}
}
}
},
"custom-cert-ext": {
"title": "Custom Certificate Extension",
"type": "object",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["cert-extension"],
"default": "cert-extension",
"options": {
"hidden": true
}
},
"name":{
"title": "Extension",
"type": "string",
"watch": {
"name": "certificate-extensions"
},
"enumSource": [
{
"source": "name",
"filter": "customCertAttrFilter",
"value": "enumValueCustomCertAttr"
}
]
},
"filter": {
"title": "Filter Value by",
"type": "string",
"default": "*"
}
}
},
"vlan-assignment": {
"title": "VLAN assignment",
"required": true,
"type": "object",
"oneOf": [
{
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"title": "Static",
"options": {
"disable_collapse": true,
},
"properties": {
"state": {
"type": "string",
"required": true,
"enum": ["enabled"],
"default": "enabled",
"options": {
"hidden": true
}
},
"type": {
"type": "string",
"required": true,
"enum": ["static"],
"default": "static",
"options": {
"hidden": true
}
},
"vlanid": {
"title": "VLAN ID",
"additionalProperties": false,
"disable_edit_json": true,
"type": "integer"
}
}
},
{
"title": "By Certificate Extension",
"$ref": "#/definitions/custom-cert-ext"
},
{
"title": "By Certificate Subject Name",
"type": "object",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["cert-subject"],
"default": "cert-subject",
"options": {
"hidden": true
}
},
"identifier": {
"title": "Distinguished Name attribute",
"type": "string",
"enum": ["CN", "OU", "O", "SN", "L"]
},
"prefix": {
"title": "Prefix",
"type": "string",
"default": "vlan-"
}
}
},
{
"$ref": "#/definitions/disabledOption"
}
],
"default": {
"state": "disabled"
}
},
"configuration-lan": {
"title": "Configuration",
"type": "object",
"collapsed": true,
"options": {
"disable_collapse": true
},
"properties": {
"switch": {
"title": "Which Switch MAC addresses are allowed(any if disabled)",
"oneOf": [
{
"$ref": "#/definitions/disabledOption"
}, {
"title": "Addresses",
"type": "object",
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["switch-mac-addresses"],
"default": "switch-mac-addresses",
"options": {
"hidden": true
}
},
"addresses": {
"title": "Addresses",
"type": "array",
"format": "table",
"options": {
"disable_array_reorder": true
},
"items": {
"title": "MAC address",
"type": "string",
"default": "any"
}
}
}
}, {
"title": "Groups",
"type": "array",
"required": true,
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "Name",
"type": "string",
"watch": {
"name": "groups",
"type": "groups.type"
},
"enumSource": [
["any"], {
"source": "name",
"filter": "switchgroupFilter",
"title": "enumTitleSwitchGroup",
"value": "enumValueSwitchGroup"
}
]
}
}
]
},
"vlan": {
"$ref": "#/definitions/vlan-assignment"
}
}
},
"configuration-wifi": {
"title": "Configuration",
"type": "object",
"collapsed": true,
"options": {
"disable_collapse": true
},
"properties": {
"ssids": {
"title": "Which SSIDs are allowed (any if disabled)",
"oneOf": [
{
"$ref": "#/definitions/disabledOption"
}, {
"title": "Names",
"type": "object",
"options": {
"disable_collapse": true
},
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["ssid-names"],
"default": "ssid-names",
"options": {
"hidden": true
}
},
"names": {
"title": "Name",
"type": "array",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "SSID Name",
"type": "string",
"default": "any"
}
}
}
}, {
"type": {
"type": "string",
"required": true,
"enum": ["ssid-groups"],
"default": "ssid-groups",
"options": {
"hidden": true
}
},
"title": "Groups",
"type": "array",
"required": true,
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "Name",
"type": "string",
"watch": {
"name": "groups",
"type": "groups.type"
},
"enumSource": [
["any"], {
"source": "name",
"filter": "ssidgroupFilter",
"title": "enumTitleSSIDGroup",
"value": "enumValueSSIDGroup"
}
]
}
}
]
},
"aps": {
"title": "Which Access Point MAC addresses are allowed(any if disabled)",
"oneOf": [
{
"$ref": "#/definitions/disabledOption"
}, {
"title": "Addresses",
"type": "object",
"options": {
"disable_collapse": true
},
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["ap-mac-addresses"],
"default": "ap-mac-addresses",
"options": {
"hidden": true
}
},
"addresses": {
"title": "Addresses",
"type": "array",
"format": "table",
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "MAC address",
"type": "string",
"default": "any"
}
}
}
}, {
"title": "Groups",
"type": "array",
"required": true,
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "Name",
"type": "string",
"watch": {
"name": "groups",
"type": "groups.type"
},
"enumSource": [
["any"], {
"source": "name",
"filter": "apgroupFilter",
"title": "enumTitleAPGroup",
"value": "enumValueAPGroup"
}
]
}
}
]
},
"vlan": {
"$ref": "#/definitions/vlan-assignment"
}
}
},
"wifi": {
"title": "WiFi Rule",
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"collapsed": true,
"options": {
"disable_collapse": true
},
"allOf": [
{
"$ref": "#/definitions/ruleBase"
}
],
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["wifi"],
"default": "wifi",
"options": {
"hidden": true
}
},
"authentication": {
"$ref": "#/definitions/authenticaton"
},
"configuration": {
"$ref": "#/definitions/configuration-wifi"
}
}
},
"lan": {
"title": "LAN Rule",
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"collapsed": true,
"options": {
"disable_collapse": true
},
"allOf": [
{
"$ref": "#/definitions/ruleBase"
}
],
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["lan"],
"default": "lan",
"options": {
"hidden": true
}
},
"authentication": {
"propertyOrder": 4,
"$ref": "#/definitions/authenticaton"
},
"configuration": {
"$ref": "#/definitions/configuration-lan"
}
}
},
"authenticaton": {
"title": "Authentication",
"type": "object",
"collapsed": true,
"options": {
"disable_collapse": true
},
"properties": {
"cert": {
"title": "Certificate-based authentication",
"type": "object",
"required": true,
"collapsed": true,
"options": {
"disable_collapse": true,
},
"oneOf": [
{
"$ref": "#/definitions/disabledOption"
}, {
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"title": "enabled",
"properties": {
"type": {
"type": "string",
"required": true,
"default": "cert",
"options": {
"hidden": true
}
},
"state": {
"type": "string",
"required": true,
"enum": ["enabled"],
"default": "enabled",
"options": {
"hidden": true
}
},
"roots": {
"title": "Filter allowed certificates(any if disabled)",
"oneOf": [
{
"$ref": "#/definitions/disabledOption"
}, {
"title": "Allowed trusted roots",
"type": "array",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true,
},
"items": {
"title": "Certificate Subject",
"type": "string",
"watch": {
"subject": "trustedroots"
},
"enumSource": [
{
"source": "subject",
"filter": "trustedrootFilter",
"title": "enumTitleTrustedRoot",
"value": "enumValueTrustedRoot"
}
]
}
}
]
},
"intuneids": {
"title": "Filter allowed Intune IDs(any if disabled)",
"oneOf": [
{
"$ref": "#/definitions/disabledOption"
},
{
"title": "Ignore",
"type": "object",
"options": {
"disable_array_reorder": true,
"disable_collapse": true,
"collapsed": true
},
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["ignore"],
"default": "ignore",
"options": {
"hidden": true
}
}
}
},
{
"title": "Allowed Intune IDs",
"type": "array",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "Intune ID",
"type": "string",
"watch": {
"id": "intuneids"
},
"enumSource": [
{
"source": "id",
"filter": "intuneidFilter",
"title": "enumTitleIntuneid",
"value": "enumValueIntuneid"
}
]
}
}
]
}
}
}
]
},
"password": {
"title": "Username/Password-based authentication",
"required": true,
"type": "object",
"collapsed": true,
"options": {
"disable_collapse": true
},
"oneOf": [
{
"$ref": "#/definitions/disabledOption"
}, {
"type": "object",
"additionalProperties": false,
"title": "enabled",
"options": {
"disable_collapse": true
},
"properties": {
"type": {
"type": "string",
"required": true,
"default": "password",
"options": {
"hidden": true
}
},
"state": {
"type": "string",
"required": true,
"enum": ["enabled"],
"default": "enabled",
"options": {
"hidden": true
}
},
"username-regex": {
"title": "User name Regex",
"type": "string",
"default": ".*"
},
"owner-rule": {
"options": {
"infoText": "Infotext"
},
"title": "Owner Regex",
"type": "string",
"default": ".*"
}
}
}
],
"default": {
"state": "disabled"
}
}
}
},
"disabledOption": {
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"title": "disabled",
"options": {
"collapsed": true,
"disable_edit_json": true,
"disable_properties": true,
"disable_collapse": true,
},
"properties": {
"state": {
"type": "string",
"required": true,
"enum": ["disabled"],
"default": "disabled",
"options": {
"hidden": true
}
}
}
},
"ssid-group": {
"title": "SSID Group",
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"uniqueItems": true,
"collapsed": true,
"options": {
"disable_collapse": true
},
"allOf": [
{
"$ref": "#/definitions/groupBase"
}
],
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["ssid-group"],
"default": "ssid-group",
"options": {
"hidden": true
}
},
"ssid-group": {
"title": " ",
"type": "array",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "SSID",
"type": "string"
}
}
}
},
"ap-group": {
"title": "AP Group",
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"uniqueItems": true,
"collapsed": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true,
},
"allOf": [
{
"$ref": "#/definitions/groupBase"
}
],
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["ap-mac-group"],
"default": "ap-mac-group",
"options": {
"hidden": true
}
},
"macs": {
"title": " ",
"type": "array",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "MAC address",
"type": "string",
"default": "any"
}
}
}
},
"switch-group": {
"title": "Switch Group",
"type": "object",
"additionalProperties": false,
"disable_edit_json": true,
"uniqueItems": true,
"collapsed": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"allOf": [
{
"$ref": "#/definitions/groupBase"
}
],
"properties": {
"type": {
"type": "string",
"required": true,
"enum": ["switch-mac-group"],
"default": "switch-mac-group",
"options": {
"hidden": true
}
},
"macs": {
"title": " ",
"type": "array",
"format": "table",
"uniqueItems": true,
"options": {
"disable_array_reorder": true,
"disable_collapse": true
},
"items": {
"title": "MAC address",
"type": "string",
"default": "any"
}
}
}
}
},
"properties": {
"rules": {
"type": "array",
"title": "Rule collection",
"uniqueItems": true,
"format": "tabs-top",
"options": {
"disable_array_reorder": false,
"disable_collapse": true,
"infoText": "Infotext"
},
"items": {
"title": "Rule",
"headerTemplate": "{{ self.name }} -- {{#self.enabled}}Enabled{{/self.enabled}}{{^self.enabled}}Disabled{{/self.enabled}}",
"oneOf": [
{
"$ref": "#/definitions/generic"
}, {
"$ref": "#/definitions/wifi"
}, {
"$ref": "#/definitions/lan"
}
]
}
},
"groups": {
"type": "array",
"title": "SSID & MAC Groups",
"uniqueItems": true,
"format": "tabs-top",
"collapsed": true,
"options": {
"disable_array_reorder": false,
"disable_collapse": true,
"infoText": "Infotext"
},
"items": {
"title": "Group",
"headerTemplate": "{{ self.name }}",
"oneOf": [
{
"$ref": "#/definitions/ssid-group"
}, {
"$ref": "#/definitions/ap-group"
}, {
"$ref": "#/definitions/switch-group"
}
]
}
},
"certificate-extensions": {
"type": "array",
"title": "Certificate Extensions",
"uniqueItems": true,
"format": "table",
"collapsed": true,
"options": {
"disable_array_reorder": "true",
"disable_collapse": true,
"infoText": "Infotext"
},
"items": {
"title": "Extension",
"properties":{
"name": {
"title": "Name",
"type": "string"
},
"oid": {
"title": "OID",
"type": "string"
}
}
}
},
"trustedroots": {
"type": "array",
"title": "Trusted Roots",
"options": {
"hidden": true
},
"items": {
"title": "Cert object",
"type": "object",
"properties": {
"subject": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
},
"intuneids": {
"type": "array",
"title": "Intune IDs",
"options": {
"hidden": true
},
"items": {
"title": "Intune ID",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
}
}
}
var editor = new JSONEditor(document.getElementById('editor_holder'), {
iconlib: 'fontawesome5',
disable_array_delete_all_rows: true,
no_additional_properties: true,
disable_edit_json: true,
input_size: 'small',
disable_properties: true,
disable_array_delete_last_row: true,
template: 'mustache',
schema: schema
})
JSONEditor.defaults.custom_validators.push(function(schema, value, path) {
var errors = [];
if(path==="root.certificate-extensions") {
$.each(value, function(i, val){
if((/\s/.test(val.oid))) {
// Errors must be an object with `path`, `property`, and `message`
errors.push({
path: path,
property: 'oid',
message: 'Whitespaces not allowed'
});
}
else if (!(/^[\.0-9]*$/.test(val.oid))){
errors.push({
path: path,
property: 'oid',
message: 'Not a valid OID'
});
}
})
}
return errors;
});
window.JSONEditor.defaults.callbacks.template = {
"switchgroupFilter": (editor, e) => {
if (e.item.type.toLowerCase() !== 'switch-mac-group')
return "";
return e.item.type;
},
"enumTitleSwitchGroup": (editor, e) => e.item.name,
"enumValueSwitchGroup": (editor, e) => e.item.name,
"ssidgroupFilter": (editor, e) => {
if (e.item.type.toLowerCase() !== 'ssid-group')
return "";
return e.item.type;
},
"enumTitleSSIDGroup": (editor, e) => e.item.name,
"enumValueSSIDGroup": (editor, e) => e.item.name,
"apgroupFilter": (editor, e) => {
if (e.item.type.toLowerCase() !== 'ap-mac-group')
return "";
return e.item.type;
},
"enumTitleAPGroup": (editor, e) => e.item.name,
"enumValueAPGroup": (editor, e) => e.item.name,
"trustedrootFilter": (editor, e) => e.item.subject,
"enumTitleTrustedRoot": (editor, e) => e.item.subject,
"enumValueTrustedRoot": (editor, e) => e.item.subject,
"intuneidFilter": (editor, e) => e.item.id,
"enumTitleIntuneid": (editor, e) => e.item.id,
"enumValueIntuneid": (editor, e) => e.item.id,
"customCertAttrFilter": (editor, e) => e.item.name,
"enumValueCustomCertAttr": (editor, e) => e.item.name + "=" + e.item.oid
};```
Could you create a simpler example reproduction the problem?
@schmunk42 Yes sorry.
Within creating a smaller example, it seems that the problem is within oneOf in the third depth
Example which is causing crash
{
"title": " ",
"type": "object",
"options": {
"disable_collapse": true
},
"properties": {
"root": {
"type": "array",
"title": " ",
"items": {
"title": "Root Object",
"oneOf": [
{
"$ref": "#/definitions/depth1"
}
]
}
}
},
"definitions": {
"depth1": {
"title": "Depth 1 Object",
"type": "object",
"properties": {
"depth2ref": {
"$ref": "#/definitions/depth2"
}
}
},
"depth2": {
"title": "Depth 2 Object",
"type": "object",
"properties": {
"depth3ref": {
"$ref": "#/definitions/depth3"
}
}
},
"depth3": {
"title": "Depth 3 Object",
"required": true,
"type": "object",
"oneOf": [
{
"type": "object",
"title": "Depth3 oneof",
"properties": {
"state": {
"type": "string",
"required": true,
"enum": [
"enabled"
],
"default": "enabled"
}
}
}
]
}
}
}
Example which is working(without oneOf in third depth)
{
"title": " ",
"type": "object",
"options": {
"disable_collapse": true
},
"properties": {
"root": {
"type": "array",
"title": " ",
"items": {
"title": "Root Object",
"oneOf": [
{
"$ref": "#/definitions/depth1"
}
]
}
}
},
"definitions": {
"depth1": {
"title": "Depth 1 Object",
"type": "object",
"properties": {
"depth2ref": {
"$ref": "#/definitions/depth2"
}
}
},
"depth2": {
"title": "Depth 2 Object",
"type": "object",
"properties": {
"depth3ref": {
"$ref": "#/definitions/depth3"
}
}
},
"depth3": {
"title": "Depth 3 Object",
"required": true,
"type": "object",
"properties": {
"test": {
"type": "string"
}
}
}
}
}
Both examples are working in version 2.6.1 and starts at 2.7
Probably related: https://github.com/json-editor/json-editor/issues/1158
This issue was fixed. Feel free to reopen.
Great stuff. It's working on a first look. Thanks!!