Page MenuHomePhabricator

api.wikimedia.org fatal exception: Error: Call to a member function text() on string
Closed, ResolvedPublicPRODUCTION ERROR

Description

Currently, api.wikimedia.org is unavailable for logged in users. Issue appears to be related to skin, investigation underway to clarify issue.

Error displays to users as:

"MediaWiki internal error.

Original exception: [3293668c-31c9-44a7-aef7-1ae85edd9ebb] 2021-08-25 14:52:22: Fatal exception of type "Error"

Exception caught inside exception handler.

Set $wgShowExceptionDetails = true; at the bottom of LocalSettings.php to show detailed debugging information."


Error
normalized_message
[{reqId}] {exception_url}   Error: Call to a member function text() on string
exception.trace
from /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/Component/NotificationAlertComponent.php(63)
#0 /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/ComponentFactory.php(320): MediaWiki\Skin\WikimediaApiPortal\Component\NotificationAlertComponent->__construct(ExtensionRegistry, User, array)
#1 /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/ComponentFactory.php(121): MediaWiki\Skin\WikimediaApiPortal\ComponentFactory->createNotificationAlertComponent(MediaWiki\Skin\WikimediaApiPortal\WikimediaApiPortalTemplate)
#2 /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/WikimediaApiPortalTemplate.php(42): MediaWiki\Skin\WikimediaApiPortal\ComponentFactory->createMainComponent(MediaWiki\Skin\WikimediaApiPortal\WikimediaApiPortalTemplate)
#3 /srv/mediawiki/php-1.37.0-wmf.20/includes/skins/SkinTemplate.php(135): MediaWiki\Skin\WikimediaApiPortal\WikimediaApiPortalTemplate->execute()
#4 /srv/mediawiki/php-1.37.0-wmf.20/includes/skins/SkinTemplate.php(150): SkinTemplate->generateHTML()
#5 /srv/mediawiki/php-1.37.0-wmf.20/includes/OutputPage.php(2644): SkinTemplate->outputPage()
#6 /srv/mediawiki/php-1.37.0-wmf.20/includes/MediaWiki.php(939): OutputPage->output(boolean)
#7 /srv/mediawiki/php-1.37.0-wmf.20/includes/MediaWiki.php(952): MediaWiki::{closure}()
#8 /srv/mediawiki/php-1.37.0-wmf.20/includes/MediaWiki.php(559): MediaWiki->main()
#9 /srv/mediawiki/php-1.37.0-wmf.20/index.php(53): MediaWiki->run()
#10 /srv/mediawiki/php-1.37.0-wmf.20/index.php(46): wfIndexMain()
#11 /srv/mediawiki/w/index.php(3): require(string)
#12 {main}
Impact
Notes

Event Timeline

Sorry, this is ugly, but was fast to paste.

{
  "_index": "logstash-deploy-2021.08.25",
  "_type": "_doc",
  "_id": "qNDMfXsB1RMACsoSQXqn",
  "_score": 1,
  "_source": {
    "timestamp": "2021-08-25T14:52:22+00:00",
    "host": "mw2271",
    "program": "mediawiki",
    "caught_by": "entrypoint",
    "referrer": "https://api.wikimedia.org/",
    "ip": "10.192.48.93",
    "facility": "user",
    "mwversion": "1.37.0-wmf.20",
    "http_method": "GET",
    "server": "api.wikimedia.org",
    "wiki": "apiportalwiki",
    "shard": "s5",
    "@timestamp": "2021-08-25T14:52:22.456Z",
    "message": "[3293668c-31c9-44a7-aef7-1ae85edd9ebb] /wiki/API_reference   Error: Call to a member function text() on string",
    "url": "/wiki/API_reference",
    "servergroup": "appserver",
    "type": "mediawiki",
    "logsource": "mw2271",
    "exception_url": "/wiki/API_reference",
    "level": "ERROR",
    "normalized_message": "[{reqId}] {exception_url}   Error: Call to a member function text() on string",
    "reqId": "3293668c-31c9-44a7-aef7-1ae85edd9ebb",
    "message_checksum": "1b25bdf0288d5d55dffaaf52aedc7e88",
    "@version": 1,
    "channel": "exception",
    "severity": "err",
    "monolog_level": 400,
    "phpversion": "7.2.34-18+0~20210223.60+debian10~1.gbpb21322+wmf1",
    "tags": [
      "input-kafka-rsyslog-udp-localhost",
      "rsyslog-udp-localhost",
      "kafka",
      "es",
      "es"
    ],
    "exception": {
      "file": "/srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/Component/NotificationAlertComponent.php:63",
      "class": "Error",
      "message": "Call to a member function text() on string",
      "trace": "from /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/Component/NotificationAlertComponent.php(63)\n#0 /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/ComponentFactory.php(320): MediaWiki\\Skin\\WikimediaApiPortal\\Component\\NotificationAlertComponent->__construct(ExtensionRegistry, User, array)\n#1 /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/ComponentFactory.php(121): MediaWiki\\Skin\\WikimediaApiPortal\\ComponentFactory->createNotificationAlertComponent(MediaWiki\\Skin\\WikimediaApiPortal\\WikimediaApiPortalTemplate)\n#2 /srv/mediawiki/php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/WikimediaApiPortalTemplate.php(42): MediaWiki\\Skin\\WikimediaApiPortal\\ComponentFactory->createMainComponent(MediaWiki\\Skin\\WikimediaApiPortal\\WikimediaApiPortalTemplate)\n#3 /srv/mediawiki/php-1.37.0-wmf.20/includes/skins/SkinTemplate.php(135): MediaWiki\\Skin\\WikimediaApiPortal\\WikimediaApiPortalTemplate->execute()\n#4 /srv/mediawiki/php-1.37.0-wmf.20/includes/skins/SkinTemplate.php(150): SkinTemplate->generateHTML()\n#5 /srv/mediawiki/php-1.37.0-wmf.20/includes/OutputPage.php(2644): SkinTemplate->outputPage()\n#6 /srv/mediawiki/php-1.37.0-wmf.20/includes/MediaWiki.php(939): OutputPage->output(boolean)\n#7 /srv/mediawiki/php-1.37.0-wmf.20/includes/MediaWiki.php(952): MediaWiki::{closure}()\n#8 /srv/mediawiki/php-1.37.0-wmf.20/includes/MediaWiki.php(559): MediaWiki->main()\n#9 /srv/mediawiki/php-1.37.0-wmf.20/index.php(53): MediaWiki->run()\n#10 /srv/mediawiki/php-1.37.0-wmf.20/index.php(46): wfIndexMain()\n#11 /srv/mediawiki/w/index.php(3): require(string)\n#12 {main}",
      "code": 0
    }
  },
  "fields": {
    "@timestamp": [
      "2021-08-25T14:52:22.456Z"
    ]
  }
}
Lucas_Werkmeister_WMDE changed the subtype of this task from "Task" to "Production Error".Aug 25 2021, 2:57 PM
Zabe triaged this task as Unbreak Now! priority.Aug 25 2021, 2:58 PM
Lucas_Werkmeister_WMDE renamed this task from api.wikimedia.org fatal exception to api.wikimedia.org fatal exception: Error: Call to a member function text() on string.Aug 25 2021, 2:58 PM
Lucas_Werkmeister_WMDE lowered the priority of this task from Unbreak Now! to Needs Triage.
Lucas_Werkmeister_WMDE triaged this task as Unbreak Now! priority.
Lucas_Werkmeister_WMDE set Request URL to https://api.wikimedia.org/wiki/Documentation.
Lucas_Werkmeister_WMDE updated the task description. (Show Details)
Lucas_Werkmeister_WMDE set Phatality ID to 8254d379453afdb3b71f24eb36973f39ab6eeafbab023c95497f988abc19a2e2.

ugh, phabricator, I didn’t mean to change the priority

Educated guess based on a quick look at the code: In NotificationAlertComponent line 63, 'title' => $notificationAlert['text']->text() needs to be replaced by 'title' => $notificationAlert['text'].

$notificationAlert comes from the personal_urls field in the skin data, according to ComponentFactory. personal_urls is populated in SkinTemplate::buildPersonalUrls. The code there sets the 'text' fields to HTML strings, not Message objects.

I couldn't find where the 'notifications-alert' entry comes from, but I assume it would have the same structure as other entries in the personal_urls array.

Given that there's. bit of uncertainty in why this is appearing at this time, an alternative for a triage fix might be:

'title' => is_string($notificationAlert['text']) ? $notificationAlert['text'] : $notificationAlert['text']->text()

Or alternatively, test if $notificationAlert['text'] is an object and adjust the ternary operator accordingly.

Per Slack discussion, though, it may be that notification just haven't happened on a wiki using this skin until now, so this problem has always existed but never surfaced.

Change 714788 had a related patch set uploaded (by Cicalese; author: Cicalese):

[mediawiki/skins/WikimediaApiPortal@master] Remove call to text() on string.

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

Change 714788 merged by jenkins-bot:

[mediawiki/skins/WikimediaApiPortal@master] Remove call to text() on string.

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

Is https://gerrit.wikimedia.org/r/714788 ready to be cherry-picked to the wmf/1.37.0-wmf.20 branch?

I think so. Fix is confirmed on https://api.wikimedia.beta.wmflabs.org/ by both myself and @apaskulin

I'm unavoidably afk for a bit. Tagging @CCicalese_WMF as I don't see her currently subscribed to this task.

Thanks. Yes, agreed, it is ready to be cherry-picked to the wmf/1.37.0-wmf.20 branch.

Change 714679 had a related patch set uploaded (by Jforrester; author: Cicalese):

[mediawiki/skins/WikimediaApiPortal@wmf/1.37.0-wmf.20] Remove call to text() on string.

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

Change 714679 merged by jenkins-bot:

[mediawiki/skins/WikimediaApiPortal@wmf/1.37.0-wmf.20] Remove call to text() on string.

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

Mentioned in SAL (#wikimedia-operations) [2021-08-25T18:23:38Z] <urbanecm@deploy1002> Synchronized php-1.37.0-wmf.20/skins/WikimediaApiPortal/src/Component/NotificationAlertComponent.php: a5bfcc8def96ad1b44fff31c4c1965311be2982a: Remove call to text() on string (T289692) (duration: 01m 04s)

Zabe assigned this task to CCicalese_WMF.

Seems to be fixed.

The root cause of this was this change: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Echo/+/713957. Is it possible that this will cause issues in other skins?

If my change in Echo makes a skin fails like this, than the code before was not correct or was trying to fix the bad behaviour of the Echo extension.

From the code the skin takes 'text' as string and a key 'msg' as messge to parse it with text()

But it is hard to tell from codesearch - only one other place found, but that is safe for message or string
https://codesearch.wmcloud.org/search/?q=%27text%27%5Cs*%5B)%5C%5D%5D%5Cs*-%3E%5Cs*text&i=nope&files=&excludeFiles=&repos=