Skip to content

fix(core): preserve field validation messages on list hook crash#9837

Open
envsecure wants to merge 1 commit intokeystonejs:mainfrom
envsecure:fix/validation-hook-error-loss
Open

fix(core): preserve field validation messages on list hook crash#9837
envsecure wants to merge 1 commit intokeystonejs:mainfrom
envsecure:fix/validation-hook-error-loss

Conversation

@envsecure
Copy link
Copy Markdown
Contributor

Description

This PR fixes two related issues in the Keystone validation hook pipeline:

  1. Validation Feedback Loss: Previously, if field-level validation hooks added messages but the list-level validation hook threw an exception (crashed), all field-level validation messages were lost. The user would only see the crash error. This PR ensures that validation messages are prioritized and thrown even if the list hook crashes.
  2. Stale Error Tags: The internal error tags for validation hooks were still using the old validateInput name, while the public API has been renamed to validate. This caused confusing error messages like An error occurred while running "validateInput". They now correctly say validate.

Changes

  • Modified packages/core/src/lib/core/hooks.ts to capture list hook errors and check for validation messages before rethrowing.
  • Updated all validateInput tags to validate.
  • Added a changeset.

Impact

  • Better UX: Users get all their validation feedback even if there are runtime errors in the list-level hooks.
  • API Consistency: Error messages now match the names of the hooks defined in the user's schema.

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