Page MenuHomePhabricator

"The provided authentication token is either expired or invalid" when editing a temporary accounts wiki with mobile VisualEditor as an anon user
Closed, ResolvedPublicBUG REPORT

Description

What is the problem?

If I edit on mobile as an anonymous user on a wiki with temporary accounts enabled, after submitting I am redirected to https://login.wikimedia.org/wiki/Special:CentralLogin/start?token=<token> with error The provided authentication token is either expired or invalid.

It does appear that the temporary account is created successfully on the wiki I was editing.

I have reproduced on https://test.wikipedia.org, https://de.wikipedia.beta.wmflabs.org and on my local.

I have only been able to reproduced it with the VisualEditor.

Steps to reproduce problem
  1. Go to https://test.m.wikipedia.org/wiki/Staple_right
  2. Make sure you are not logged in as either a named or temporary account
  3. Make an edit with the VisualEditor

Expected behaviour: After clicking "Publish", you are redirected back to https://test.m.wikipedia.org/wiki/Staple_right, and are now logged in as a temporary user.
Observed behaviour: You end up on https://login.wikimedia.org/wiki/Special:CentralLogin/start?token=<token> with the The provided authentication token is either expired or invalid error.

Environment

Browser: Firefox 115, iPhone 14 Safari.
Wiki(s): https://test.wikipedia.org MediaWiki 1.43.0-wmf.15 (b30ac00) 22:23, 22 July 2024. MobileFrontend 2.4.1 (438b5e8) 07:25, 22 July 2024.
Editor: Mobile VisualEditor – (81580e9) 07:26, 22 July 2024.

Screenshots

bs_realios_Mobile_iPhone 14-16.0.jpg (458×903 px, 38 KB)

Event Timeline

I was able to make an edit successfully using Firefox (on desktop) in private browsing mode on test.m.wikipedia.org and stay logged in as a temp account. When I tried in private browsing mode on Safari iOS, I see the same error noted in the task description.

I notice that after publishing on desktop VE as an anon user I am returned to the page but the new edit does not show and I am still shown as logged out (even though an account has been created in the background). I don't know if this is related. So far, I have only reproduced this on https://test.wikipedia.org on Firefox.

I can reproduce this on Chrome and Firefox when using https://test.m.wikipedia.org.

I have confirmed that this problem does not occur with DiscussionTools.

Token store expiry is one minute so that seems unlikely. The central login code tries for up to three seconds to read the store, so it's probably not replication lag either. At this point no cross-domain cookies are involved (this is step 4 of T363699#9980913 failing) so I can't see a way of browser privacy limitations being relevant. The data is deleted from the token store once retrieved, so my guess would be the URL is somehow accessed twice. (Some kind of preloading, maybe?) If you can reliably reproduce the issue, maybe you can verify that via the webrequest table?

image.png (1,082×326 px, 79 KB)

Here are the requests I see. The api.php request is the one to post the VisualEditor edit. The 604504 request is a failed attempt to save client hints.

image.png (1,082×326 px, 79 KB)

Here are the requests I see. The api.php request is the one to post the VisualEditor edit. The 604504 request is a failed attempt to save client hints.

I filed the duplicate POST requests for client hints data as T370771: Client hints attempts to post data for old / incorrect revision ID on temp account creation. I don't think it's related, though, because we see the duplicate failed POST requests for client hints data on desktop as well, but with an eventual successful redirect back from login.wikimedia.org to testwiki.

So yeah there are two start requests (I assume that's Special:CentralLogin/start on loginwiki), with the first cancelled (but probably still reaching the servers). Given this only happens in VisualEditor, probably an issue there?

Maybe the code in VisualEditor that does location.href = ... to perform the redirect runs twice somehow? It's a bit gnarly with a bunch of callbacks jumping between DesktopArticleTarget and ArticleTarget.

kostajh renamed this task from "The provided authentication token is either expired or invalid" when editing a temporary accounts wiki on mobile as an anon user to "The provided authentication token is either expired or invalid" when editing a temporary accounts wiki with mobile VisualEditor as an anon user.Aug 19 2024, 5:20 AM

If it's mobile-only, it's simpler than @matmarex was worried about, because DesktopArticleTarget isn't in the picture. Instead, EditorOverlayBase.onSaveComplete in MobileFrontend and ArticleTarget.saveComplete in VE are stepping on each other's toes and both doing a redirect uncritically. It used to not matter very much, because ArticleTarget only redirected on new-page-creation, and a double-redirect there wasn't awful, but now there's this new condition...

That said, the MobileFrontend spot that's doing the redirect is being told that there's a temp user created, so I think it should be fine to just have it not do any redirects for that case.

Change #1063828 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/MobileFrontend@master] Temp user creation: stop VE and EditorOverlayBase from both redirecting

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

kostajh moved this task from Code Review to QA on the Editing-team (Kanban Board) board.

This is in QA on two team's boards, but I think it only needs to be done by one team's QA (whoever gets to it first?)

Change #1063828 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Temp user creation: stop VE and EditorOverlayBase from both redirecting

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

I cannot reproduce this bug on various beta sites, various devices, new and existing articles.

For regression purposes, I tested editing as a logged in user.