Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayField component throws exception when formData prop is null #2153

Closed
3 tasks done
TheRealJon opened this issue Dec 2, 2020 · 0 comments · Fixed by #2154
Closed
3 tasks done

ArrayField component throws exception when formData prop is null #2153

TheRealJon opened this issue Dec 2, 2020 · 0 comments · Fixed by #2154

Comments

@TheRealJon
Copy link
Contributor

TheRealJon commented Dec 2, 2020

Prerequisites

Description

When formData for an array field is malformed, a runtime error can be thrown.

Steps to Reproduce

  1. See jsFiddle example
  2. In the formData field, enter: { "foo": null }

Expected behavior

Null value should be handled gracefully without throwing an exception

Actual behavior

An uncaught exception is thrown from ArrayField.getDerivedStateFromProps

Version

Tested on 1.7.0 and 2.4.0

TheRealJon added a commit to TheRealJon/console that referenced this issue Dec 2, 2020
In some cases, an uncaught exception could be thrown from dynamically generated array form fields.
This was happening when a nested array field had an explicitly set 'null' value. This is a
workaround that adds a fallback value to object and array fields to prevent this runtime error. An
issue and fix have also been opened upstream in the react-jsonschema-form repo.
rjsf-team/react-jsonschema-form#2153
rjsf-team/react-jsonschema-form#2154
bipuladh pushed a commit to bipuladh/console that referenced this issue Dec 14, 2020
In some cases, an uncaught exception could be thrown from dynamically generated array form fields.
This was happening when a nested array field had an explicitly set 'null' value. This is a
workaround that adds a fallback value to object and array fields to prevent this runtime error. An
issue and fix have also been opened upstream in the react-jsonschema-form repo.
rjsf-team/react-jsonschema-form#2153
rjsf-team/react-jsonschema-form#2154
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant