This repository was archived by the owner on Feb 5, 2026. It is now read-only.
Refactor error handling in REST API run controller#31
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR standardizes error handling in the REST API abilities run controller by introducing consistent error codes for different types of validation failures and moving validation logic from the REST controller into the core WP_Ability class.
- Replaced generic REST error codes with specific ability-related error codes for better error identification
- Moved input/output validation from REST controller to WP_Ability class to centralize validation logic
- Updated permission handling to properly propagate input validation errors
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
includes/rest-api/endpoints/class-wp-rest-abilities-run-controller.php |
Removed duplicate validation methods and updated error codes for method and permission checks |
includes/abilities-api/class-wp-ability.php |
Enhanced validation methods to return standardized WP_Error objects and improved error propagation in execute method |
tests/unit/rest-api/wpRestAbilitiesRunController.php |
Updated test assertions to expect new standardized error codes |
tests/unit/abilities-api/wpRegisterAbility.php |
Updated test assertions and removed expected incorrect usage warnings |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
justlevine
approved these changes
Aug 20, 2025
Member
Author
|
I forgot to remove in progress status 😄 Yes, it should be ready to land. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
WP_ErrorfromWP_Abilitymethods #23It addresses the following refactoring:
This PR standardizes error handling in the REST API abilities run controller by introducing consistent error codes for different types of validation failures and moving validation logic from the REST controller into the core WP_Ability class.
Testing
Run
npm run test:phpand make sure all tests pass.