What is the problem?
I can get the reportincident API endpoint (rest.php/reportincident/v0/report/) to return this error:
[error] [95ddb8d85aff8e32cb752e77] /w/rest.php/reportincident/v0/report PHP Warning: Trying to access array offset on value of type null #0 /var/www/html/w/extensions/ReportIncident/src/Api/Rest/Handler/ReportHandler.php(88): MWExceptionHandler::handleError() #1 /var/www/html/w/includes/Rest/SimpleHandler.php(38): MediaWiki\Extension\ReportIncident\Api\Rest\Handler\ReportHandler->run() #2 /var/www/html/w/includes/Rest/Router.php(517): MediaWiki\Rest\SimpleHandler->execute() #3 /var/www/html/w/includes/Rest/Router.php(422): MediaWiki\Rest\Router->executeHandler() #4 /var/www/html/w/includes/Rest/EntryPoint.php(195): MediaWiki\Rest\Router->execute() #5 /var/www/html/w/includes/Rest/EntryPoint.php(135): MediaWiki\Rest\EntryPoint->execute() #6 /var/www/html/w/rest.php(31): MediaWiki\Rest\EntryPoint::main() #7 {main} .... [exception] [95ddb8d85aff8e32cb752e77] /w/rest.php/reportincident/v0/report InvalidArgumentException: Scalar parameter must be a string, number, or MessageValue; got NULL #0 /var/www/html/w/includes/libs/Message/MessageValue.php(77): Wikimedia\Message\ScalarParam->__construct() #1 /var/www/html/w/includes/libs/Message/MessageValue.php(35): Wikimedia\Message\MessageValue->params() #2 /var/www/html/w/extensions/ReportIncident/src/Api/Rest/Handler/ReportHandler.php(92): Wikimedia\Message\MessageValue->__construct() #3 /var/www/html/w/includes/Rest/SimpleHandler.php(38): MediaWiki\Extension\ReportIncident\Api\Rest\Handler\ReportHandler->run() #4 /var/www/html/w/includes/Rest/Router.php(517): MediaWiki\Rest\SimpleHandler->execute() #5 /var/www/html/w/includes/Rest/Router.php(422): MediaWiki\Rest\Router->executeHandler() #6 /var/www/html/w/includes/Rest/EntryPoint.php(195): MediaWiki\Rest\Router->execute() #7 /var/www/html/w/includes/Rest/EntryPoint.php(135): MediaWiki\Rest\EntryPoint->execute() #8 /var/www/html/w/rest.php(31): MediaWiki\Rest\EntryPoint::main() #9 {main}
This happens when a logged-in user with permission to submit the report incident form sends in a request that uses form data.
Steps to reproduce problem
- Setup a wiki with ReportIncident installed
- Login to an account that has not submitted a incident report within the last day.
- Run this command in your browser console (this performs a request to the API with form data) after replacing http://localhost:8080 with the domain name of the wiki you are using:
await fetch("http://localhost:8080/w/rest.php/reportincident/v0/report", { "headers": { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0", "Accept": "application/json, text/javascript, */*; q=0.01", "Accept-Language": "en-GB,en;q=0.5", "Content-Type": "application/x-www-form-urlencoded", "X-Requested-With": "XMLHttpRequest", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "Pragma": "no-cache", "Cache-Control": "no-cache" }, "referrer": "http://localhost:8080/wiki/User_talk:Dreamyjazz", "body": "foobar", "method": "POST" });
What happens
I get a 500 server error as shown above
What should happen
A 4XX error (an error code starting with a 4) should be returned.
Environment
Wiki(s): 1.42.0-alpha (72f7b7a) 12:57, 18 October 2023. ReportIncident (b42b772) 12:22, 18 October 2023.