Skip to content

fix(entity-editor): prevent server crash when form submitted after page refresh#1231

Open
Prateekiiitg56 wants to merge 1 commit intometabrainz:masterfrom
Prateekiiitg56:fix/entity-editor-refresh-crash
Open

fix(entity-editor): prevent server crash when form submitted after page refresh#1231
Prateekiiitg56 wants to merge 1 commit intometabrainz:masterfrom
Prateekiiitg56:fix/entity-editor-refresh-crash

Conversation

@Prateekiiitg56
Copy link

Description

Fixes server crash that occurs when users refresh the entity-editor page after filling the form and then submit.

Problem

When a user:

  1. Fills out the entity-editor form
  2. Refreshes the browser page
  3. Submits the form

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

  • Server-side defensive programming: Added null/undefined checks in sanitizeBody() and processSingleEntity() to handle missing data gracefully
  • Early validation: Check for required fields (aliases, name, sortName) before processing
  • Error handling: Wrapped transformation logic in try-catch with informative error messages
  • Client-side validation: Added pre-submission checks to catch incomplete state on the client
  • User guidance: Clear error messages instructing users to refill form after refresh

Testing

  • ✅ Code compiles successfully with no errors
  • ✅ Prevents crashes from malformed data
  • ✅ Provides user-friendly error messages
  • Manual testing recommended: Fill form → Refresh page → Submit → Verify error message instead of crash

…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.
Copilot AI review requested due to automatic review settings February 17, 2026 16:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() and processSingleEntity()) 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments