Page MenuHomePhabricator

action=help&toc=1: Caught exception of type TypeError
Closed, ResolvedPublicPRODUCTION ERROR

Description

Steps to replicate the issue:

Make an action=help API call with toc=1 (e.g. this).

What happens?:

{
    "error": {
        "code": "internal_api_error_TypeError",
        "info": "[8e4c60be-8654-49b2-b4c7-c63150d49476] Caught exception of type TypeError",
        "errorclass": "TypeError"
    },
    "servedby": "mw2418"
}

What should have happened instead?:
MediaWiki should have returned the HTML content with TOC added.


TypeError: Argument 5 passed to Wikimedia\Parsoid\Core\SectionMetadata::__construct() must be of the type string, bool given, called in /srv/mediawiki/php-1.41.0-wmf.4/vendor/wikimedia/parsoid/src/Core/SectionMetadata.php

Error
normalized_message
[{reqId}] {exception_url}   TypeError: Argument 5 passed to Wikimedia\Parsoid\Core\SectionMetadata::__construct() must be of the type string, bool given, called in /srv/mediawiki/php-1.41.0-wmf.4/vendor/wikimedia/parsoid/src/Core/SectionMetadata.php on line 303
exception.trace
from /srv/mediawiki/php-1.41.0-wmf.4/vendor/wikimedia/parsoid/src/Core/SectionMetadata.php(157)
#0 /srv/mediawiki/php-1.41.0-wmf.4/vendor/wikimedia/parsoid/src/Core/SectionMetadata.php(303): Wikimedia\Parsoid\Core\SectionMetadata->__construct(integer, integer, string, string, boolean, NULL, NULL, string, string, NULL)
#1 /srv/mediawiki/php-1.41.0-wmf.4/vendor/wikimedia/parsoid/src/Core/TOCData.php(200): Wikimedia\Parsoid\Core\SectionMetadata::fromLegacy(array)
#2 [internal function]: Wikimedia\Parsoid\Core\TOCData::Wikimedia\Parsoid\Core\{closure}(array)
#3 /srv/mediawiki/php-1.41.0-wmf.4/vendor/wikimedia/parsoid/src/Core/TOCData.php(199): array_map(Closure, array)
#4 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiHelp.php(189): Wikimedia\Parsoid\Core\TOCData::fromLegacy(array)
#5 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiHelp.php(77): ApiHelp::getHelp(DerivativeContext, array, array)
#6 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiMain.php(1908): ApiHelp->execute()
#7 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiMain.php(884): ApiMain->executeAction()
#8 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiMain.php(855): ApiMain->executeActionWithErrorHandling()
#9 /srv/mediawiki/php-1.41.0-wmf.4/api.php(91): ApiMain->execute()
#10 /srv/mediawiki/php-1.41.0-wmf.4/api.php(46): wfApiMain()
#11 /srv/mediawiki/w/api.php(3): require(string)
#12 {main}

Event Timeline

Aklapper changed the subtype of this task from "Bug Report" to "Production Error".Apr 12 2023, 7:48 AM
Aklapper set Request URL to https://www.mediawiki.org/w/api.php?action=help&modules=*&toc=*.
Aklapper updated the task description. (Show Details)
Aklapper set Release Version to 1.41.0-wmf.4.
hashar triaged this task as Unbreak Now! priority.Apr 12 2023, 10:12 AM
hashar updated the task description. (Show Details)
hashar added a project: Content-Transform-Team.
hashar subscribed.

I have flagged it as a train blocker since it is apparently new to 1.41.0-wmf.4

I can reproduce this on enwiki (f3b41f5d-9ad3-4ced-8b6d-4a39762dd365) which is on 1.41.0-wmf.3.

This is not a new failure -- there is no new code from Parsoid on this train and as Zabe notes, this is present on the previous train as well. But, in any case, this is probably something in core (ApiHelp.php) and we should be able to fix it there to conform to the signature. Something that probably slipped past us when we were working on TOC changes in Feb and March.

But, unless there is a big spike of these errors, I don't think this is a UBN.

Change 908259 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/core@master] Ensure ApiHelp correctly types values in TOCData objects

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

I guess we can still move forward with the train and handle the backport this week when the patch got reviewed/merged. Given it is an old issue with few occurrences, it might not be worth blocking the train on it.

Change 908259 merged by jenkins-bot:

[mediawiki/core@master] Ensure ApiHelp correctly types values in TOCData objects

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

ssastry lowered the priority of this task from Unbreak Now! to Medium.Apr 12 2023, 6:24 PM

I am going to be bold and mark this *not UBN*.

Oh, the patch is merged now anyway.

Change 908289 had a related patch set uploaded (by Jforrester; author: Subramanya Sastry):

[mediawiki/core@wmf/1.41.0-wmf.4] Ensure ApiHelp correctly types values in TOCData objects

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

Change 908290 had a related patch set uploaded (by Jforrester; author: Subramanya Sastry):

[mediawiki/core@wmf/1.41.0-wmf.3] Ensure ApiHelp correctly types values in TOCData objects

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

Change 908290 merged by jenkins-bot:

[mediawiki/core@wmf/1.41.0-wmf.3] Ensure ApiHelp correctly types values in TOCData objects

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

Change 908289 merged by jenkins-bot:

[mediawiki/core@wmf/1.41.0-wmf.4] Ensure ApiHelp correctly types values in TOCData objects

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

Mentioned in SAL (#wikimedia-operations) [2023-04-12T19:30:51Z] <zabe@deploy2002> Started scap: Backport for [[gerrit:908291|composer.json: Explicitly pin psr/http-message to 1.0.1 (T333993)]], [[gerrit:908290|Ensure ApiHelp correctly types values in TOCData objects (T334551)]], [[gerrit:908289|Ensure ApiHelp correctly types values in TOCData objects (T334551)]]

Mentioned in SAL (#wikimedia-operations) [2023-04-12T19:32:12Z] <zabe@deploy2002> jforrester and zabe: Backport for [[gerrit:908291|composer.json: Explicitly pin psr/http-message to 1.0.1 (T333993)]], [[gerrit:908290|Ensure ApiHelp correctly types values in TOCData objects (T334551)]], [[gerrit:908289|Ensure ApiHelp correctly types values in TOCData objects (T334551)]] synced to the testservers: mwdebug1001.eqiad.wmnet, mwdebug2002.codfw.wmnet, mwdebug2001.codfw.wmnet, mwdebug1002.

This now causes the following error, reverting fix on prod for now.

[977b6475-f293-46e5-b175-d5a6efb7d810] /w/api.php?action=help&modules=main&toc=1   Error: Cannot unpack array with string keys
	
from /srv/mediawiki/php-1.41.0-wmf.4/vendor/wikimedia/parsoid/src/Core/TOCData.php(204)
#0 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiHelp.php(189): Wikimedia\Parsoid\Core\TOCData::fromLegacy(array)
#1 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiHelp.php(77): ApiHelp::getHelp(DerivativeContext, array, array)
#2 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiMain.php(1908): ApiHelp->execute()
#3 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiMain.php(884): ApiMain->executeAction()
#4 /srv/mediawiki/php-1.41.0-wmf.4/includes/api/ApiMain.php(855): ApiMain->executeActionWithErrorHandling()
#5 /srv/mediawiki/php-1.41.0-wmf.4/api.php(91): ApiMain->execute()
#6 /srv/mediawiki/php-1.41.0-wmf.4/api.php(46): wfApiMain()
#7 /srv/mediawiki/w/api.php(3): require(string)
#8 {main}

Okay, looks like there is more digging to be done here.

Testing locally, even if I revert Scott's patch, looks like the TOC on the API help page has been broken from other TOC changes we had been landing since last year. Anyway, additional patches coming.

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/885871 also caused the new breakage. When I fix that I find that the TOC is empty which was caused by https://gerrit.wikimedia.org/r/c/mediawiki/core/+/862391. Fix coming.

Change 908348 had a related patch set uploaded (by Subramanya Sastry; author: Subramanya Sastry):

[mediawiki/core@master] Fix breakages generating TOC for API Help pages

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

Change 908348 merged by jenkins-bot:

[mediawiki/core@master] Fix breakages generating TOC for API Help pages

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