Skip to content

fix(core): remediate validation feedback loss and access control silent errors#9838

Open
envsecure wants to merge 1 commit intokeystonejs:mainfrom
envsecure:fix/remediated-core-validation-and-access-control
Open

fix(core): remediate validation feedback loss and access control silent errors#9838
envsecure wants to merge 1 commit intokeystonejs:mainfrom
envsecure:fix/remediated-core-validation-and-access-control

Conversation

@envsecure
Copy link
Copy Markdown
Contributor

Description

This PR provides a comprehensive fix for several issues in the KeystoneJS core, including those that led to CI failures in previous attempts (PR #9837).

Key Improvements:

  1. Validation Feedback Preservation:
    • Fixed an issue where field-level validation messages were lost if a list-level validation hook threw an exception.
    • Field validation messages are now prioritized and preserved even during list-level hook crashes, providing better feedback to users.
  2. Access Control Robustness:
    • Resolved a silent error in checkUniqueItemExists where database errors (connection timeouts, etc.) were being swallowed.
    • These errors are now correctly rethrown, while preserving the "item may not exist" logic for actual access denied cases.
  3. Build & Type Stability:
    • Simplified the complex generic type signatures in hooks.ts that were causing Preconstruct/Rollup build failures (MISSING_EXPORT).
    • Standardized export patterns and import styles to ensure consistent behavior across bundling tools.
  4. API Consistency:
    • Updated internal error tags and documentation from validateInput to validate to align with the current public API names.

Changes

  • Modified packages/core/src/lib/core/hooks.ts
  • Modified packages/core/src/lib/core/access-control.ts
  • Modified packages/core/src/types/config/hooks.ts
  • Added two changesets for the respective fixes.

Verification

  • The logic has been audited to ensure no regressions in hook execution order or field-level hook filtering.
  • The build-breaking complex generics have been refactored into simpler, more robust patterns.

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