fix(entity-editor): prevent server crash when form submitted after page refresh#1231
Open
Prateekiiitg56 wants to merge 1 commit intometabrainz:masterfrom
Open
fix(entity-editor): prevent server crash when form submitted after page refresh#1231Prateekiiitg56 wants to merge 1 commit intometabrainz:masterfrom
Prateekiiitg56 wants to merge 1 commit intometabrainz:masterfrom
Conversation
…ge refresh - Add defensive checks in sanitizeBody() to handle missing/invalid aliases array - Add early validation in processSingleEntity() to catch malformed data - Improve error handling in makeEntityCreateOrEditHandler() with better messages - Add client-side validation in submit() to check for incomplete state - Provide user-friendly error messages suggesting page refresh resolution Fixes form submission crash that occurs when: 1. User fills entity-editor form 2. User refreshes the page (Redux state resets but HTML inputs retain values) 3. User submits form (sends empty/initial Redux state instead of form values) This prevents server crashes and guides users to refill the form after refresh. Addresses issue reported on community forum regarding entity editor crashes.
There was a problem hiding this comment.
Pull request overview
This PR fixes a server crash that occurs when users refresh the entity-editor page after filling the form and then submit. The root cause is that Redux store resets to initial state on page refresh while HTML inputs visually retain their values, resulting in empty/malformed data being submitted to the server.
Changes:
- Added defensive null/undefined checks in server-side functions (
sanitizeBody()andprocessSingleEntity()) to handle missing or malformed data - Implemented early validation with clear error messages for required fields (aliases, name, sortName) on both server and client
- Wrapped
transformNewForm()call in try-catch to gracefully handle transformation errors
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/server/routes/entity/entity.tsx | Added defensive checks in sanitizeBody() for aliases array and disambiguation, plus early validation in processSingleEntity() for required fields |
| src/server/helpers/entityRouteUtils.tsx | Added validation checks for req.body, nameSection, and submissionSection before processing, with try-catch around transformNewForm() |
| src/client/entity-editor/submission-section/actions.ts | Added client-side pre-submission validation to check for required state fields (nameSection, aliasEditor) before submitting |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
Fixes server crash that occurs when users refresh the entity-editor page after filling the form and then submit.
Problem
When a user:
The server would crash because the Redux store resets to initial state on refresh, but HTML inputs visually retain their values. Upon submission, the form sends empty/malformed Redux state instead of the actual form input values.
Changes
sanitizeBody()andprocessSingleEntity()to handle missing data gracefullyTesting