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
Fix incorrect allOf merging (fix #2923) (Reimplement #3025) #3227
Conversation
2cb40f2
to
552d69e
Compare
…if/then/else statements fail to render correctly
- Fix a case where an invalid schema type (e.g. a string) may be passed to `computeDefaults`. - Fix an issue where `toPathSchema` only recognized `additionalProperties` in schema objects if `additionalProperties` was strictly `true` when the value of `additionalProperties` could be a JSON Schema object.
552d69e
to
0555715
Compare
parentDefaults?: T, | ||
rootSchema: S = {} as S, | ||
rawFormData?: T, | ||
includeUndefinedValues: boolean | "excludeObjectChildren" = false | ||
): T | T[] | undefined { | ||
const formData = isObject(rawFormData) ? rawFormData : {}; | ||
let schema: S = isObject(rawSchema) ? rawSchema : ({} as S); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a test that passes an invalid schema and expects a specific error message. The test fails without this change because a string ends up getting passed here as rawSchema
, and we don't get to the error case that the test does expect.
The best fix would be to actually validate the schema before we get this far, but that would be a large change that would require a lot of effort.
schema[ADDITIONAL_PROPERTIES_KEY] === true | ||
schema[ADDITIONAL_PROPERTIES_KEY] !== false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the path schema to decide which objects to drop when we use omitExtraData
. For some reason, a change here uncovered a case where the additionalProperty fields would be dropped by omitExtraData
+ liveOmit
if the additionalProperties
schema was an object. This fixes that regression.
@nickgros Can you list which actual issues this will fix in the description? Or do we just not know? Or at least list the ones that we think this MIGHT fix and let them reopen if it doesn't? |
I looked through and found that this fixes #2923. The gist is that the previous merge algorithm was incorrect, and @AlimovSV 's reproduction in #2923 proves it by showing a case where incorrectly-merged subschemas returned errors when the raw AJV validation resulted in no errors. After this change, RJSF creates correct subschemas, and no errors are returned for valid data. |
…am#3025) (rjsf-team#3227) Co-authored-by: Sergey Alimov <sergey.alimov@gmail.com> Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com> Fixes rjsf-team#2923
…am#3025) (rjsf-team#3227) Co-authored-by: Sergey Alimov <sergey.alimov@gmail.com> Co-authored-by: Heath C <51679588+heath-freenome@users.noreply.github.com> Fixes rjsf-team#2923
See #3025 for more information.
It's currently hard to verify the issue in the playground because the examples seem to trigger an infinite loop of some sort that crash the page.
Fixes #2923
Checklist
npm run test:update
to update snapshots, if needed.