What is the problem?
I can get the client hints API endpoint (rest.php/checkuser/v0/useragent-clienthints/revision/) to return this error:
[exception] [30b80b4c154e277391656329] /bare/rest.php/checkuser/v0/useragent-clienthints/revision/6890 TypeError: Argument 1 passed to MediaWiki\CheckUser\ClientHints\ClientHintsData::newFromJsApi() must be of the type array, null given, called in /home/drw/wikimedia/srv/bare/extensions/CheckUser/src/Api/Rest/Handler/UserAgentClientHintsHandler.php on line 55 #0 /home/drw/wikimedia/srv/bare/extensions/CheckUser/src/Api/Rest/Handler/UserAgentClientHintsHandler.php(55): MediaWiki\CheckUser\ClientHints\ClientHintsData::newFromJsApi() #1 /home/drw/wikimedia/srv/bare/includes/Rest/SimpleHandler.php(38): MediaWiki\CheckUser\Api\Rest\Handler\UserAgentClientHintsHandler->run() #2 /home/drw/wikimedia/srv/bare/includes/Rest/Router.php(517): MediaWiki\Rest\SimpleHandler->execute() #3 /home/drw/wikimedia/srv/bare/includes/Rest/Router.php(422): MediaWiki\Rest\Router->executeHandler() #4 /home/drw/wikimedia/srv/bare/includes/Rest/EntryPoint.php(195): MediaWiki\Rest\Router->execute() #5 /home/drw/wikimedia/srv/bare/includes/Rest/EntryPoint.php(135): MediaWiki\Rest\EntryPoint->execute() #6 /home/drw/wikimedia/srv/bare/rest.php(31): MediaWiki\Rest\EntryPoint::main() #7 {main}
I think it happens when you try to pass it something that isn't JSON.
Steps to reproduce problem
- Setup a wiki with CheckUser installed and client hints enabled (they are by default)
- Run this command (You may need to change the value of the server to point to your local wiki):
curl 'http://localhost:8080/w/rest.php/checkuser/v0/useragent-clienthints/revision/6890' -H 'Content-Type: application/x-www-form-urlencoded' --data-raw 'foobar'
I have tried other content types, but so far I have only been able to reproduce it with Content-Type: application/x-www-form-urlencoded.
Environment
Wiki(s): MediaWiki 1.41.0-alpha (e20dc2f) 14:13, 7 August 2023. CheckUser 2.5 (bfcb3ae) 04:46, 24 August 2023.