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

Setting Form prop extraErrors changes the structure of propagated error objects #2579

Closed
3 tasks done
iwan-uschka opened this issue Oct 11, 2021 · 5 comments
Closed
3 tasks done
Labels

Comments

@iwan-uschka
Copy link

Prerequisites

Description

If extraErrors is set as a <Form /> prop (it just needs to be an empty object) the errors array (in the transformErrors or onError callback) doesn't provide the same error object data structure.

With extraErrors being set:

[
  {stack: 'salutation: Is required.'},
  ...
]

Without extraErrors being set:

[
  {
    message: "is a required property",
    name: "required",
    params: {missing Property: 'salutation'},
    property: ".address.salutation",
    schemaPath: "#/properties/address/required",
    stack: ".address.salutation is a required property
  },
  ...
]

Is this behavior intentional? I couldn't find any hint in the docs.

Expected behavior

I would like to have internal errors being defined as detailed as possible no matter if some external extraErrors are brought into the error stack.

Actual behavior

Internal errors are becoming less detailed if external extraErrors are set.

See https://codesandbox.io/s/interesting-hertz-vo5ef?file=/src/App.js using 3.1.0.

If i use the JSFiddle template from above (which is using 1.8.1 as it seems, see https://unpkg.com/react-jsonschema-form/dist/react-jsonschema-form.js) the "error" doesn't occur. See https://jsfiddle.net/01qwf23d/4/.

Version

3.1.0

@jacqueswho jacqueswho added the bug label Feb 22, 2022
@hughjdavey
Copy link

hughjdavey commented Nov 29, 2022

This also seems to happen if you use the customValidation option - even if your custom validation function just returns errors unchanged like

function validate(formData, errors) {
    return errors;
}

If I don't use customValidation, I get error stacks like .contact_info.address.line1 is a required property but when it is set, the stacks all become e.g. line1: is a required property.

This is on ^4.1.1 btw.

@hughjdavey
Copy link

I have made a JSFiddle for this - https://jsfiddle.net/mdeazLy3/1/

There are 2 forms, one with a validate function and one without. The one with the function returns truncated error.stacks:

image

@hughjdavey
Copy link

Since this is old I opened #3262 - let me know if that wasn't the right thing to do

@heath-freenome
Copy link
Member

Since this is old I opened #3262 - let me know if that wasn't the right thing to do

@hughjdavey I'm treating #3262 as a documentation bug and will fix that one accordingly. I believe that the specific bug in this issue is already fixed in the v5 beta... Closing this accordingly

@iwan-uschka
Copy link
Author

iwan-uschka commented Nov 12, 2023

A little late but we're finally in the process of migrating to rjsf@5 and i can confirm that this error has been fixed. Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants