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

ResolveAllReferences fails with a deeply frozen schema #3805

Closed
4 tasks done
schen-fn opened this issue Aug 2, 2023 · 0 comments · Fixed by #3806
Closed
4 tasks done

ResolveAllReferences fails with a deeply frozen schema #3805

schen-fn opened this issue Aug 2, 2023 · 0 comments · Fixed by #3806
Labels

Comments

@schen-fn
Copy link
Contributor

schen-fn commented Aug 2, 2023

Prerequisites

What theme are you using?

utils

Version

5.11.1

Current Behavior

I'm using a frozen schema via Object.freeze(). With the latest release my unit tests are failing. I'm getting this error:

TypeError: Cannot assign to read only property 'payment_type' of object '#<Object>'
      at node_modules/@rjsf/utils/src/schema/retrieveSchema.ts:216:43

Expected Behavior

I expect to not get any errors with a patch release

Steps To Reproduce

  1. have a schema use oneOf with refs in it
  2. freeze this schema using Object.freeze()
  3. call retrieveSchema with it

Environment

- OS: macOS Ventura 13.4
- Node: v18.17.0
- npm: 9.6.7

Anything else?

No response

@schen-fn schen-fn added bug needs triage Initial label given, to be assigned correct labels and assigned labels Aug 2, 2023
@heath-freenome heath-freenome removed the needs triage Initial label given, to be assigned correct labels and assigned label Aug 2, 2023
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Aug 2, 2023
…y updating them

Fixes rjsf-team#3805 by using object spread of schema changes rather than direct updating of schema properties

- In `@rjsf/utils`, updated `resolveAllReferences()` to copy updated schema properties rather than directly changing them to avoid issues with frozen schemas
- In `@rjsf/material-ui`, removed the unnecessary import of the `@types/material-ui` which was causing typescript issues in some situations
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Aug 2, 2023
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Aug 2, 2023
…y updating them

Fixes rjsf-team#3805 by using object spread of schema changes rather than direct updating of schema properties

- In `@rjsf/utils`, updated `resolveAllReferences()` to copy updated schema properties rather than directly changing them to avoid issues with frozen schemas
- In `@rjsf/material-ui`, removed the unnecessary import of the `@types/material-ui` which was causing typescript issues in some situations
heath-freenome added a commit to heath-freenome/react-jsonschema-form that referenced this issue Aug 2, 2023
heath-freenome added a commit that referenced this issue Aug 2, 2023
…g them (#3806)

* fix: Fixes #3805 by copying schema props rather than directly updating them

Fixes #3805 by using object spread of schema changes rather than direct updating of schema properties

- In `@rjsf/utils`, updated `resolveAllReferences()` to copy updated schema properties rather than directly changing them to avoid issues with frozen schemas
- In `@rjsf/material-ui`, removed the unnecessary import of the `@types/material-ui` which was causing typescript issues in some situations

* - Added deep freeze of schema used for testing to verify #3805
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants