React-jsonschema-form: Better logging for schema issues

Created on 22 Feb 2019  路  5Comments  路  Source: rjsf-team/react-jsonschema-form

Description

When using a large schema, it can be hard to find the specific schema issue from the log warnings. I recently received:

ignoring oneOf in dependencies because there isn't exactly one subschema that is valid

I know there is an issue with the dependency schema for my form, but unfortunately I have several oneOf dependencies for several refs and I'm having trouble tracking down which one this refers to.

Steps to Reproduce

Create a form with an invalid dependency schema using oneOf

Expected behavior

I'd love to know which schema key this refers to in the console log that outputs when the form knows there is an issue. An external validator tool could be another solution.

Actual behavior

Generic warning in console:

ignoring oneOf in dependencies because there isn't exactly one subschema that is valid

Version

1.2.1

enhancement help wanted

All 5 comments

Just better errorHandling in general would be good.

I'm working on a live form builder.

Existing formSchema is loaded into a json editor a user can then edit/add to that jsonSchema, however when adding a new property in the json editor it starts by creating an empty object, the live preview form updates and throws an error instantly.

utils.js:232 Uncaught TypeError: Cannot use 'in' operator to search for 'default' in null
    at computeDefaults (utils.js:232)
    at eval (utils.js:256)
    at Array.reduce (<anonymous>)
    at computeDefaults (utils.js:253)
    at getDefaultFormState (utils.js:291)
    at Form.getStateFromProps (Form.js:178)
    at Form.componentWillReceiveProps (Form.js:160)
    at callComponentWillReceiveProps (react-dom.development.js:11826)
    at updateClassInstance (react-dom.development.js:12039)
    at updateClassComponent (react-dom.development.js:15071)
    at beginWork (react-dom.development.js:16064)
    at performUnitOfWork (react-dom.development.js:20084)
    at workLoop (react-dom.development.js:20125)
    at HTMLUnknownElement.callCallback (react-dom.development.js:147)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:196)
    at invokeGuardedCallback (react-dom.development.js:250)
    at replayUnitOfWork (react-dom.development.js:19308)
    at renderRoot (react-dom.development.js:20238)
    at performWorkOnRoot (react-dom.development.js:21162)
    at performWork (react-dom.development.js:21072)
    at performSyncWork (react-dom.development.js:21046)
    at interactiveUpdates$1 (react-dom.development.js:21331)
    at interactiveUpdates (react-dom.development.js:2268)
    at dispatchInteractiveEvent (react-dom.development.js:5086)

It would be nice if the form would continue to render ignoring the invalid property.

@paintedbicycle @chinds185a Can you please give me playground links to the particular scenarios that caused confusing error messages?

Hi @epicfaace I'm sure there are other examples, but the exact one I came up against was this

Inside the the person ref, I simply changed:

              "properties": {
                "Do you have any pets?": {
                  "enum": [
                    "Yes: More than one"
                  ]
                },

to

              "properties": {
                "Do your have any pets?": {
                  "enum": [
                    "Yes: More than one"
                  ]
                },

Note the typo your in only one of the property definitions. So there is a mismatch.

If you open the console, you'll see:

ignoring oneOf in dependencies because there isn't exactly one subschema that is valid

Now, in my case, there were many of these anyOf properties. And I would have liked the warning message to simply tell me which one it was.

For example:

ignoring Do you have any pets? oneOf dependency because subschema is not valid

Makes sense, thanks for the report.

Code pointer is here: https://github.com/mozilla-services/react-jsonschema-form/blob/d9bcf1acfa3fd15814654129054b3c65501f5271/src/utils.js#L607

@paintedbicycle would you have the bandwidth to submit a PR improving the warning message here?

@epicfaace Ok, you can reference https://github.com/mozilla-services/react-jsonschema-form/pull/1224

I tried to do a very small change here, but it might be beneficial to update other warnings around the lib. But I don't know the code well enough.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ebower12 picture ebower12  路  3Comments

j-zimnowoda picture j-zimnowoda  路  3Comments

elyobo picture elyobo  路  3Comments

epicfaace picture epicfaace  路  3Comments

n1k0 picture n1k0  路  3Comments