ERA-13745: V1 cleared enum/dropdown field fails "must be equal to one of the allowed values" validation on re-save#1660
Merged
Merged
Conversation
- Added a new utility function, `filterOutEnumErrorsForClearedFields`, to handle enum validation errors for fields that have been cleared (set to empty or undefined). - Updated the `transformErrors` function in `DetailsSection` to utilize the new error filtering logic. - Enhanced tests in `event-schemas.test.js` to cover various scenarios for cleared fields, ensuring proper handling of enum errors based on schema requirements. - Adjusted the `ReportDetailView` tests to validate saving behavior when dealing with cleared dropdowns and their associated enum validations.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a legacy (v1) event-details form issue where clearing an enum/dropdown field can produce a spurious AJV enum validation error (“must be equal to one of the allowed values”) and prevent re-saving an event. It adds an error-filtering utility and wires it into the legacy form error transformation, with accompanying unit and integration-style tests.
Changes:
- Added
filterOutEnumErrorsForClearedFieldsto remove enum validation errors when the corresponding field is cleared (unless the schema marks it as required). - Updated
DetailsSectionlegacytransformErrorsto apply the new filtering before hidden-property filtering. - Expanded Jest coverage in
event-schemas.test.jsandReportDetailViewtests for cleared dropdown save/reopen scenarios and required-field behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/utils/event-schemas.js |
Adds cleared-enum error filtering + required-field detection helper. |
src/utils/event-schemas.test.js |
Adds unit tests covering cleared enum filtering for flat/nested/array paths and required schema behavior. |
src/ReportManager/DetailsSection/index.js |
Integrates the new filter into legacy form transformErrors. |
src/ReportManager/ReportDetailView/index.test.js |
Adds regression tests ensuring cleared legacy dropdowns can be saved/reopened, and required dropdowns still block saving. |
…r malformed schemas - Updated the `isFieldRequired` function to ensure it correctly checks if the `required` property is an array before validating keys. - Added a new test case in `event-schemas.test.js` to verify that the function handles malformed `required` properties gracefully, ensuring no errors are thrown and enum errors are filtered correctly.
chrisj-er
approved these changes
Jul 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Implement error filtering for cleared fields in event details
filterOutEnumErrorsForClearedFields, to handle enum validation errors for fields that have been cleared (set to empty or undefined).transformErrorsfunction inDetailsSectionto utilize the new error filtering logic.event-schemas.test.jsto cover various scenarios for cleared fields, ensuring proper handling of enum errors based on schema requirements.ReportDetailViewtests to validate saving behavior when dealing with cleared dropdowns and their associated enum validations.Relevant link(s)