Page MenuHomePhabricator

Rest ParamValidator should support validation of fields in the request body
Closed, ResolvedPublic

Description

Per T357025 we can get the parsed contents of the request body from HandlerInterface::getParsedBody. This allows ParamValidator to validate body fields in the same way it validates form data. We just need to add support for the "body" source to ParamValidatorCallbacks::getParamsFromSource().

NOTE: This solution is insufficient to cover the need to fail on extraneous fields in the request body. One possible solution would be to provide a method that can explicitly be called from execute() that will perform the necessary check. This way, handlers that need this check can op into applying it in a straight-forward way.

Event Timeline

Change 1006873 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/core@master] paramValidator: Add case body to get parsed json

https://gerrit.wikimedia.org/r/1006873

daniel triaged this task as Medium priority.Feb 29 2024, 4:45 PM

Change 1006873 merged by jenkins-bot:

[mediawiki/core@master] paramValidator: Add case body to get parsed json

https://gerrit.wikimedia.org/r/1006873

Change #1014651 had a related patch set uploaded (by Atieno; author: Atieno):

[mediawiki/core@master] handler: Declare know sources in Validator

https://gerrit.wikimedia.org/r/1014651

Change #1014651 merged by jenkins-bot:

[mediawiki/core@master] handler: Declare known sources in Validator

https://gerrit.wikimedia.org/r/1014651