Repository navigation
Abilities API: Accept PUT for destructive and idempotent abilities in the run endpoint - #16257
sajid-ansari-65 wants to merge 3 commits into
Conversation
… the run endpoint. Destructive and idempotent abilities now expect PUT, which carries the input in a JSON body. PATCH is also accepted, and DELETE stays accepted with the input in the query string for backward compatibility. See #66801.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the endpoint’s updated HTTP-method and input-handling behavior.
No open issues 🎉
What changed in this PR
This PR updates the Abilities API run endpoint to prefer PUT for destructive, idempotent abilities, while also accepting PATCH and preserving DELETE compatibility.
Changes:
- Accept PUT and PATCH with JSON-body input; retain query-string input for DELETE.
- Update method-validation messages and documentation, and expand tests for accepted methods and input handling.
| File | Description |
|---|---|
tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php |
Adds method-validation cases, PUT query-input rejection coverage, and PUT/PATCH coercion coverage. |
src/wp-includes/rest-api/endpoints/class-wp-rest-abilities-v1-run-controller.php |
Accepts PUT and PATCH for destructive, idempotent abilities and updates related messages and documentation. |
Review effort: Balanced
|
@jorgefilipecosta, I'm just letting you know that this change is fully backward compatible. It will still require changes in the JavaScript package that handles abilities execution to account to the revised recommended way to call these abilities. |
|
Thanks for the review. For the Gutenberg follow-up, |
gziolo
left a comment
There was a problem hiding this comment.
Thank you for working on this! This is a complicated problem, because the same two annotations describe both updates and deletes. I really appreciate your work on it.
I spent more time trying to understand the MCP spec for these annotations and what it means for the REST methods. My current thinking is moving toward this mapping:
- GET for read-only abilities. The input is in the query string.
- PUT for idempotent updates, which are abilities marked
destructiveandidempotent. The input is in a JSON body. - DELETE for deletes, which have the same two annotations. The input is in the query string.
- POST for everything else, such as creates and writes that are not idempotent. The input is in a JSON body.
The PR is already close to this. What do you think?
I left three inline comments with the changes this mapping would need. The tests pass for me locally.
…point. Destructive and idempotent abilities now accept PUT for updates and DELETE for deletes. PATCH is rejected because it is not idempotent per RFC 9110. The 405 error message now names both PUT and DELETE. A PUT request that sends the input in the query string returns a 400 error, so a destructive ability does not silently run with its default input. See #66801. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review! I agree with the mapping, and I've updated the PR to follow it:
Changes in the latest commit:
One related question: a DELETE request that sends |
|
Thanks for the update, and for the good question! I'm open to a stricter check for DELETE in this PR. It should target We will need a dev note for WordPress 7.3 that explains these changes. |
DELETE reads the input only from the query string. A DELETE request that sends `input` in a JSON or form body now returns a 400 error with the `rest_ability_invalid_input_location` code, so a destructive ability does not silently run with its default input. Body data without an `input` key is still accepted. See #66801.
|
Thanks! @gziolo.
Happy to draft the 7.3 dev note as well. I can share a draft on the ticket once the approach is settled. |
Destructive and idempotent abilities now expect PUT, which carries the input in a JSON body. PATCH is also accepted, and DELETE stays accepted with the input in the query string for backward compatibility.
See #66801
Trac ticket: https://core.trac.wordpress.org/ticket/66801
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Claude Code wrote the implementation and tests, following the approach discussed in the ticket. I reviewed the diff, ran PHPUnit and PHPCS locally, and tested the endpoint with curl on a local install.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.