Page MenuHomePhabricator

GlobalWatchlist: cross-wiki request to mediawiki.org or test.wikipedia.org failing with `badtoken`
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error

You need to have mediawiki.org as one of the sites in your global watchlist. Since nothing has changed in the global watchlist code in weeks, I believe that this indicates something has changed with the API

message
An API error occurred while interacting with "www.mediawiki.org":
⧼badtoken⧽
trace
Debug.js:62 Error: GlobalWatchlistError: www.mediawiki.org:API.actuallyGetWatchlist #1 badtoken
    at Debug.js.GlobalWatchlistDebugger.error (Debug.js:56:18)
    at SiteBase.js.GlobalWatchlistSiteBase.error (SiteBase.js:84:19)
    at eval (SiteBase.js:107:9)
    at mightThrow (jquery.js:3489:29)
    at process (jquery.js:3557:12)
Impact

Changes cannot be fetched for mediawiki.org

Notes

Thankfully global watchlist has some client-side JS logging. mw.globalwatchlist.debug.debugLog.filter( ( m ) => m.includes( 'mediawiki.org:' ) ) shows for me:

"7: www.mediawiki.org:API.actuallyGetWatchlist #1 (called), with func & content:	["get",{"action":"query","formatversion":2,"list":"watchlist","wllimit":"max","wlprop":"ids|title|flags|loginfo|parsedcomment|timestamp|user|tags|expiry","wlshow":"unread","wltype":"edit|new|log","wlallrev":true}]"
"92: ERROR: www.mediawiki.org:API.actuallyGetWatchlist #1 badtoken	{"error":{"code":"badtoken","info":"⧼badtoken⧽","docref":"See https://www.mediawiki.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/postorius/lists/mediawiki-api-announce.lists.wikimedia.org/> for notice of API deprecations and breaking changes."},"servedby":"mw-api-ext.codfw.main-586d55f64d-hn5l5"}"
"93: www.mediawiki.org:getWatchlist - error"

The same problem happens with test.wikipedia.org.
See also wikitech-l.

Event Timeline

DannyS712 triaged this task as Unbreak Now! priority.Nov 7 2023, 7:18 PM
DannyS712 created this task.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
IKhitron renamed this task from GlobalWatchlist: cross-wiki request to mediawiki.org failing with `badtoken` to GlobalWatchlist: cross-wiki request to mediawiki.org or test.wikipedia.org failing with `badtoken`.Nov 7 2023, 7:22 PM
IKhitron awarded a token.
IKhitron updated the task description. (Show Details)
IKhitron subscribed.

testwiki also has GW deployed, and there (from 1.42.0-wmf.4) the api works to retrieve changes from both mediawiki.org and testwiki, but on meta when I add testwiki to the global watchlist (or presumably any other 1.42.0-wmf.4 wiki) it fails, so the issue is api requests from wmf.3 to wmf.4

matmarex added subscribers: Tgr, matmarex.

@Tgr said he'll look into it.

For what it's worth, I can reproduce this with test.wikipedia.org, but not with www.mediawiki.org.

Minimal code to reproduce is this, executed in the browser console:

await new mw.ForeignApi('https://test.wikipedia.org/w/api.php').get( { meta: 'userinfo' } )

Expected: Object { batchcomplete: "", query: {…} } (or something like this, depending on the browser)
Actual: Uncaught (in promise) badtoken (or something like this, depending on the browser)


The faulty error message "⧼badtoken⧽" is a separate problem, https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CentralAuth/+/972455 will fix that. (It seems this has always been broken, but no one has hit this code path before in sufficient numbers to notice.)

Token generation seems to work as expected:

tgr@mwmaint1002:~$ mwscript shell.php metawiki
> sudo $tokenStore = MediaWiki\Session\SessionManager::getGlobalSession()->getProvider()->sessionManager->getTokenStore()
> $token = '...'
> # when generated on meta
> $tokenStore->getMulti( [ "centralauth:api-token:$token", "global:api-token:centralauth:$token" ] )
= [
    "centralauth:api-token:..." => [...],
  ] 
> # when generated on mediawiki.org
> $tokenStore->getMulti( [ "centralauth:api-token:$token", "global:api-token:centralauth:$token" ] )
= [
    "centralauth:api-token:..." => [...],
    "global:api-token:centralauth:..." => [...],
  ]

Change 972464 had a related patch set uploaded (by Bartosz Dziewoński; author: Gergő Tisza):

[mediawiki/extensions/CentralAuth@master] Fix centralauthtoken key schema migration

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

Change 972464 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Fix centralauthtoken key schema migration

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

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

[mediawiki/extensions/CentralAuth@wmf/1.42.0-wmf.4] Fix centralauthtoken key schema migration

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

Change 972262 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@wmf/1.42.0-wmf.4] Fix centralauthtoken key schema migration

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

Mentioned in SAL (#wikimedia-operations) [2023-11-07T21:46:23Z] <tgr@deploy2002> tgr: Backport for [[gerrit:972262|Fix centralauthtoken key schema migration (T347223 T350723)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2023-11-07T21:58:20Z] <tgr@deploy2002> Finished scap: Backport for [[gerrit:972262|Fix centralauthtoken key schema migration (T347223 T350723)]] (duration: 13m 17s)

Tgr claimed this task.

Verified via Special:ApiSandbox that centralauthtokens work between meta and mediawiki.org.

Thanks - GlobalWatchlist is working properly too

Confirming it started to work in last five minutes, and I get mediawiki.org results from timestamp after the problem started.