Skip to content

null in $ref'ed schema -> TypeError: Cannot read properties of null (reading '$ref') #1383

@navytux

Description

@navytux

Hello up there.

First of all I want to say thanks for json-editor - I'm playing with it since a few days and this project seems to be handy and useful.

In one of my test I hit a crash where schema loader tries to read $ref property of null. This happens, for example, when ref'ed schema specifies null as a value of any field, for example:

---- 8< ---- (top schema.json)

{
  "$ref": "https://lab.nexedi.com/kirr/misc/raw/17f75f2/lte/schema-with-null.json"
}

---- 8< ---- (schema-with-null.json)

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",

  "properties": {
    "activity-timeout": {
      "description": "How long a CMFActivity-initiated transaction may last, in seconds",
      "default": null,
      "type": [
        "number",
        "null"
      ]
    }
  }
}

which leads to the following crash in _manageRecursivePointer:

schemaloader.js:264 Uncaught (in promise) TypeError: Cannot read properties of null (reading '$ref')
    at eval (schemaloader.js:264:1)
    at Array.forEach (<anonymous>)
    at SchemaLoader._manageRecursivePointer (schemaloader.js:263:1)
    at SchemaLoader._getExternalRefs (schemaloader.js:279:1)
    at eval (schemaloader.js:309:1)
    at Array.forEach (<anonymous>)
    at SchemaLoader._getExternalRefs (schemaloader.js:298:1)
    at eval (schemaloader.js:309:1)
    at Array.forEach (<anonymous>)
    at SchemaLoader._getExternalRefs (schemaloader.js:298:1)

Thanks beforehand,
Kirill

General information

  • json-editor version: 2.10.1-38-g06f0117 (today's master)

Expected behavior

Schema loads ok without crashing.

Actual behavior

Schema loader crashes.

Steps to reproduce the behavior

Direct link to failing example on json-editor.github.io .

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions