question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Properties not defined in JSON schema cause "TypeError"

See original GitHub issue

Expected behavior

Properties not defined in JSON schema can be added if it is allowed by the schema.

Actual behavior

Any property added to JSON and not described in JSON schema causes error in console: TypeError: can't convert null to object

Steps to reproduce the behavior

  1. Create JSON schema:
{
  "type": "object",
  "title": "Error: Properties not descibed in schema cause error",
  "description": "Create schema for one property, then add another one",
  "additionalProperties": true,
  "required": ["name"],
  "properties": {
    "name": {
      "type": "string",
      "title": "name"
    }
  }
}
  1. Load the schema into the JSON Editor, then try to add any property.
  2. The new property will be successfully added, but there will appear above mentioned error in browser console.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
Radouchcommented, Oct 17, 2018

See https://jsfiddle.net/9kcyL7g3/1/ (look at the browser console, too). There is a problem with an option: remove_empty_properties: true

0reactions
Radouchcommented, Oct 19, 2018

@pmk65 I have built dist files locally and it works ok. The issue can be closed. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Json schema validation error - Stack Overflow
Therefore you receive an error about wrong type. JSON schema type MUST be single value or array of such strings: "array","boolean","integer"," ...
Read more >
JavaScript TypeErrors and Techniques to Prevent Them
A short guide on best practices, techniques and existing tooling available to prevent TypeErrors in JavaScript or TypeScript.
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
This string has to be valid JSON and will throw this error if incorrect syntax was encountered. Examples. JSON.parse() does not allow trailing...
Read more >
API Reference | Ajv JSON schema validator
Properties not defined in the schema will not be included in serialized JSON, unless the schema has additionalProperties: true flag.
Read more >
json-schema-library - npm
to prevent some errors when using helper methods with an independent subschema, please use compileSchema if it is not retrieved from a draft- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found