-
Notifications
You must be signed in to change notification settings - Fork 82
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
(feat) O3-3790: Indicate errors in JSON schema #339
base: main
Are you sure you want to change the base?
Conversation
FYI @NethmiRodrigo |
Something weird I'm seeing is that a particular validation gets triggered up only after there has been some other error. Notice that the error notification for it doesn't get triggered the first time around as well. I had to click Screen.Recording.2024-08-22.at.12.33.07.PM.mov |
My bad, seems like this feature already existed in the |
Hi @NethmiRodrigo and @denniskigen, I have made some commits to address the current issues. Please review the updates at your convenience. You can view a demonstration of the changes here: Errors.webmThank you! |
Requirements
Summary
Error Handling in Schema Validation
This PR addresses the two types of errors we encounter when working with schemas:
1. Syntax Errors in the JSON Schema:
These errors occur when attempting to parse an invalid JSON string, typically caught using the
JSON.parse()
method. The error message should clearly guide the user on the nature and location of the issue. Previously, while we caught these errors, we did not display them to users.2. Invalid Schema According to OpenMRS Form Schema:
These errors are thrown by the Ajv JSON schema validator when validating the JSON against the
openmrs.org/form.schema.json
. This aspect has been handled correctly in the current implementation.Enhancements Introduced in This PR:
Displaying Syntax Errors: Syntax errors will now be shown to users via an
InlineNotification
, providing clear feedback on the issue.Guided Error Resolution: Users will be prompted to resolve these errors one at a time, ensuring a smoother debugging process. Therefore we can't have this:
Screenshots
Pr implementation
Screancast
This is the implementation in this PR
json-errors.webm
Related Issue
https://openmrs.atlassian.net/browse/O3-3790
Other
Previously, Ajv validation was failing due to errors in the OpenMRS form schema. However, these issues were resolved in a recent commit by @denniskigen.