Altinn / altinn-studio

Next generation open source Altinn platform and applications.
https://docs.altinn.studio
BSD 3-Clause "New" or "Revised" License
115 stars 70 forks source link

Return specific error codes when schema contains errors (e.g. empty object nodes) #11037

Open mlqn opened 1 year ago

mlqn commented 1 year ago

We currently display a generic error message when an error occurs during data model generation. I suggest improving the error messages by providing a specific message for each type of common error (e.g. empty object node), including an extra field that indicates the property path that failed. This would help users to resolve data model errors by themselves.

https://github.com/user-attachments/assets/226b64a3-8b01-4eff-ab4c-f9e1d1daa4be

https://github.com/Altinn/altinn-studio/assets/24462611/3b040e07-0c1c-499b-b778-1aca1038e97c

framitdavid commented 1 year ago

We have discussed this earlier, but when I'm testing this issue I see the need for a separate endpoint for validating the model. We should create a separate endpoint for JSON schema validation. We save right away when adding new fields/objects, so users get error messages instantly. Instead of validating on save, we should do the validation before generating the data model.

Image

framitdavid commented 1 year ago

@mirkoSekulic now my comment is staled, because of the hotfix that was done earlier today. 😊 Should we add this issue back to the backlog?

mirkoSekulic commented 1 year ago

@framitdavid Should be in backlog. We have issues with schemas with circular references when validating.

nkylstad commented 11 months ago

Validation should be done on "generate models", not in save. Validation on "empty object" is already implemented. Add validation on using same name on model and type?

How should we show errors? Per field?

framitdavid commented 11 months ago

Validation should be done on "generate models", not in save. Validation on "empty object" is already implemented. Add validation on using same name on model and type?

How should we show errors? Per field?

  • Add new issue to look at how frontend should handle this, could we also add validation frontend?

I agree with you Nina! We already have a frontend issue we can use to look further into this, https://github.com/Altinn/altinn-studio/issues/11632

ghost commented 11 months ago

@nkylstad I had a quick discussion with @Annikenkbrathen about this earlier today, specifically for the "Liste med gyldige verdier" in this issue: #11701. We suggest that we have one error pr. field, and display the error below the fields., e.g., "duplicate value" or "empty value". This shows the user what and where the errors are.

For the overall datamodel page, I agree that the validation should happen when the user clicks "generate models" through a validation API. 😄