Page MenuHomePhabricator

Error: Wrong parameters for HttpError([string $message [, long $code [, Throwable $previous = NULL]]])
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error
normalized_message
[{reqId}] {exception_url}   Error: Wrong parameters for HttpError([string $message [, long $code [, Throwable $previous = NULL]]])
exception.previous.trace
from /srv/mediawiki/php-1.44.0-wmf.19/includes/session/SessionManager.php(538)
#0 /srv/mediawiki/php-1.44.0-wmf.19/includes/session/SessionManager.php(198): MediaWiki\Session\SessionManager->getSessionInfoForRequest(MediaWiki\Request\WebRequest)
#1 /srv/mediawiki/php-1.44.0-wmf.19/includes/Request/WebRequest.php(870): MediaWiki\Session\SessionManager->getSessionForRequest(MediaWiki\Request\WebRequest)
#2 /srv/mediawiki/php-1.44.0-wmf.19/includes/user/User.php(1045): MediaWiki\Request\WebRequest->getSession()
#3 /srv/mediawiki/php-1.44.0-wmf.19/includes/user/User.php(393): MediaWiki\User\User->loadDefaults()
#4 /srv/mediawiki/php-1.44.0-wmf.19/includes/user/User.php(1603): MediaWiki\User\User->load()
#5 /srv/mediawiki/php-1.44.0-wmf.19/includes/user/Options/UserOptionsManager.php(562): MediaWiki\User\User->getName()
#6 /srv/mediawiki/php-1.44.0-wmf.19/includes/user/Options/UserOptionsManager.php(414): MediaWiki\User\Options\UserOptionsManager->getCacheKey(MediaWiki\User\User)
#7 /srv/mediawiki/php-1.44.0-wmf.19/includes/user/Options/UserOptionsManager.php(176): MediaWiki\User\Options\UserOptionsManager->loadUserOptions(MediaWiki\User\User, int)
#8 /srv/mediawiki/php-1.44.0-wmf.19/includes/context/RequestContext.php(548): MediaWiki\User\Options\UserOptionsManager->getOption(MediaWiki\User\User, string)
#9 /srv/mediawiki/php-1.44.0-wmf.19/includes/context/RequestContext.php(527): MediaWiki\Context\RequestContext->fetchSkinName()
#10 /srv/mediawiki/php-1.44.0-wmf.19/includes/context/RequestContext.php(583): MediaWiki\Context\RequestContext->getSkinName()
#11 /srv/mediawiki/php-1.44.0-wmf.19/includes/OutputTransform/Stages/HandleSectionLinks.php(215): MediaWiki\Context\RequestContext->getSkin()
#12 /srv/mediawiki/php-1.44.0-wmf.19/includes/OutputTransform/Stages/HandleSectionLinks.php(62): MediaWiki\OutputTransform\Stages\HandleSectionLinks->resolveSkin(array)
#13 /srv/mediawiki/php-1.44.0-wmf.19/includes/OutputTransform/Stages/HandleSectionLinks.php(49): MediaWiki\OutputTransform\Stages\HandleSectionLinks->replaceHeadings(string, array)
#14 /srv/mediawiki/php-1.44.0-wmf.19/includes/OutputTransform/ContentTextTransformStage.php(17): MediaWiki\OutputTransform\Stages\HandleSectionLinks->transformText(string, MediaWiki\Parser\ParserOutput, MediaWiki\Parser\ParserOptions, array)
#15 /srv/mediawiki/php-1.44.0-wmf.19/includes/OutputTransform/OutputTransformPipeline.php(80): MediaWiki\OutputTransform\ContentTextTransformStage->transform(MediaWiki\Parser\ParserOutput, MediaWiki\Parser\ParserOptions, array)
#16 /srv/mediawiki/php-1.44.0-wmf.19/includes/language/MessageParser.php(158): MediaWiki\OutputTransform\OutputTransformPipeline->run(MediaWiki\Parser\ParserOutput, MediaWiki\Parser\ParserOptions, array)
#17 /srv/mediawiki/php-1.44.0-wmf.19/includes/language/Message/Message.php(1460): MediaWiki\Language\MessageParser->parse(string, MediaWiki\Page\PageReferenceValue, bool, bool, LanguageEn)
#18 /srv/mediawiki/php-1.44.0-wmf.19/includes/language/Message/Message.php(1050): MediaWiki\Message\Message->parseText(string)
#19 /srv/mediawiki/php-1.44.0-wmf.19/includes/language/Message/Message.php(1080): MediaWiki\Message\Message->format(string)
#20 [internal function]: MediaWiki\Message\Message->__toString()
#21 /srv/mediawiki/php-1.44.0-wmf.19/includes/exception/HttpError.php(50): Exception->__construct(MediaWiki\Message\Message)
#22 /srv/mediawiki/php-1.44.0-wmf.19/includes/Setup.php(519): HttpError->__construct(int, MediaWiki\Message\Message)
#23 /srv/mediawiki/php-1.44.0-wmf.19/includes/WebStart.php(85): require_once(string)
#24 /srv/mediawiki/php-1.44.0-wmf.19/rest.php(32): require(string)
#25 /srv/mediawiki/w/rest.php(3): require(string)
#26 {main}
Impact
Notes

Details

Request URL
https://www.wikidata.org/w/rest.php/wikibase/v0/entities/lexemes/L1041834/senses
Related Changes in Gerrit:

Event Timeline

This error seems to be "Something went wrong in the process of reporting T388172"

Tgr subscribed.

Exactly one example in the last 7 days (logstash). Maybe a deploy artifact? Or maybe it's just very rare for that error to happen in the REST API (which catches most exceptions and tries to convert them into a HttpError).

But the immediate problem here is with the HttpError class, which accepts either a Message or a string as its second parameter, and then passes that to the constructor of the standard PHP Exception, which takes a string. Message has a __toString() method so that should work but apparently doesn't - maybe a PHP 8 difference?

It's seemingly on PHP 7.4 according to logstash... Have filed T387606: Including PHP version in error (and stuck up a patch) to make this more obvious in the pasted text in future though.

Nevermind, HttpError is not the same as HttpException which is used by the API. No idea what component it belongs to, but in any case the fix is trivial.

Change #1125511 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/core@master] HttpError: Cast Message to string

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

In theory the current logic should work in all PHP versions, per the PHP docs on coercive typing. Also, I can't reproduce locally - passing a Message to HttpError works. So no idea what's going on.

Change #1125511 merged by jenkins-bot:

[mediawiki/core@master] HttpError: Cast Message to string

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

Change #1126669 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_43] HttpError: Cast Message to string

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

Reedy assigned this task to Tgr.

Change #1126670 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_42] HttpError: Cast Message to string

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

Change #1126671 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_39] HttpError: Cast Message to string

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

Change #1126671 merged by jenkins-bot:

[mediawiki/core@REL1_39] HttpError: Cast Message to string

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

Change #1126670 merged by jenkins-bot:

[mediawiki/core@REL1_42] HttpError: Cast Message to string

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

Change #1126669 merged by jenkins-bot:

[mediawiki/core@REL1_43] HttpError: Cast Message to string

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