Page MenuHomePhabricator

[CLIENT] Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $title: invalid name
Open, In Progress, Needs TriagePublicPRODUCTION ERROR

Description

What happens?:
When I go to the Wikimania wiki and check my notifications on Special:Notifications, I get an error message:
[8f8b0058-2ee4-4f0f-8125-9499fe254c85] 2024-06-15 14:12:42: Fatal exception of type "Wikimedia\Assert\ParameterAssertionException". Not sure why this happens.

When I click on the icon to see the drop-down, I have a message "There are no notifications" but I see I do have two unread notifications.

Error
normalized_message
[{reqId}] {exception_url}   Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $title: invalid name 'Contributions/The_monster_is_my_thing_ill_do_this_if_'
exception.trace
from /srv/mediawiki/php-1.43.0-wmf.9/vendor/wikimedia/assert/src/Assert.php(72)
#0 /srv/mediawiki/php-1.43.0-wmf.9/includes/title/TitleValue.php(205): Wikimedia\Assert\Assert::parameter(boolean, string, string)
#1 /srv/mediawiki/php-1.43.0-wmf.9/includes/title/TitleValue.php(169): MediaWiki\Title\TitleValue::assertValidSpec(integer, string, string, string)
#2 /srv/mediawiki/php-1.43.0-wmf.9/includes/specialpage/SpecialPage.php(173): MediaWiki\Title\TitleValue->__construct(integer, string, string)
#3 /srv/mediawiki/php-1.43.0-wmf.9/includes/specialpage/SpecialPage.php(156): MediaWiki\SpecialPage\SpecialPage::getTitleValueFor(string, string, string)
#4 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Echo/includes/Formatters/EchoEventPresentationModel.php(600): MediaWiki\SpecialPage\SpecialPage::getTitleFor(string, string)
#5 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Echo/includes/Formatters/EchoEventPresentationModel.php(356): MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel->getUserLink(MediaWiki\User\User)
#6 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Wikibase/client/includes/Notifications/PageConnectionPresentationModel.php(101): MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel->getAgentLink()
#7 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Echo/includes/Formatters/SpecialNotificationsFormatter.php(80): Wikibase\Client\Notifications\PageConnectionPresentationModel->getSecondaryLinks()
#8 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Echo/includes/Formatters/EchoEventFormatter.php(77): MediaWiki\Extension\Notifications\Formatters\SpecialNotificationsFormatter->formatModel(Wikibase\Client\Notifications\PageConnectionPresentationModel)
#9 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Echo/includes/DataOutputFormatter.php(204): MediaWiki\Extension\Notifications\Formatters\EchoEventFormatter->format(MediaWiki\Extension\Notifications\Model\Event)
#10 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Echo/includes/DataOutputFormatter.php(164): MediaWiki\Extension\Notifications\DataOutputFormatter::formatNotification(MediaWiki\Extension\Notifications\Model\Event, MediaWiki\User\User, string, LanguageEn)
#11 /srv/mediawiki/php-1.43.0-wmf.9/extensions/Echo/includes/Special/SpecialNotifications.php(71): MediaWiki\Extension\Notifications\DataOutputFormatter::formatOutput(MediaWiki\Extension\Notifications\Model\Notification, string, MediaWiki\User\User, LanguageEn)
#12 /srv/mediawiki/php-1.43.0-wmf.9/includes/specialpage/SpecialPage.php(719): MediaWiki\Extension\Notifications\Special\SpecialNotifications->execute(NULL)
#13 /srv/mediawiki/php-1.43.0-wmf.9/includes/specialpage/SpecialPageFactory.php(1687): MediaWiki\SpecialPage\SpecialPage->run(NULL)
#14 /srv/mediawiki/php-1.43.0-wmf.9/includes/actions/ActionEntryPoint.php(502): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#15 /srv/mediawiki/php-1.43.0-wmf.9/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#16 /srv/mediawiki/php-1.43.0-wmf.9/includes/MediaWikiEntryPoint.php(200): MediaWiki\Actions\ActionEntryPoint->execute()
#17 /srv/mediawiki/php-1.43.0-wmf.9/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#18 /srv/mediawiki/w/index.php(3): require(string)
#19 {main}
Impact
Notes

Details

MediaWiki Version
1.43.0-wmf.9
Request URL
https://wikimania.wikimedia.org/wiki/Special:Notifications?uselang=*

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Aklapper renamed this task from Fatal exception in Echo to Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $title: invalid name.Jun 15 2024, 2:22 PM
Aklapper changed the subtype of this task from "Bug Report" to "Production Error".
Aklapper set Request URL to https://wikimania.wikimedia.org/wiki/Special:Notifications?uselang=*.
Aklapper updated the task description. (Show Details)
Aklapper set Release Version to 1.43.0-wmf.9.
  • Seems EchoEventPresentationModel.php $user->isRegistered() returns false for external (Wikibase) account. This account The monster is my thing ill do this if im thing is not registered on wikimaniawiki (and won't be).
  • The agent name is truncated resulting in _ at the end which is invalid Title.
matmarex subscribed.

More context:

So it seems that the account was treated as unregistered when creating the notification, and now there's bad data in the database.

This is probably a Wikidata-specific issue, caused by creating cross-wiki notifications when the user account only exists on one wiki.

@tarlocesilion Until this is fixed, I think you can regain access to your notifications by going to https://wikimania.wikimedia.org/wiki/Special:Preferences#mw-prefsection-echo and unchecking "Connection with Wikidata" (assuming you don't need this type of notifications).

So it seems that the account was treated as unregistered when creating the notification, and now there's bad data in the database.

Yes. Should isRegistered return true for global accounts (even no local created)? This needs to be checked also in light of forthcoming temporary accounts.

This is probably a Wikidata-specific issue, caused by creating cross-wiki notifications when the user account only exists on one wiki.

Note there are currently at least two cross-wiki kind of notifications. There is also possibility to view notifications from all wikis on one wiki (by default). This issue needs to be tested also with this.

The exception is good. There may be other unforeseen problems in future that will need to be detected this way. Non-ips should not be treated internally as IPs. Database entries needs to be fixed after fixing the code. But I agree this should not blocking whole notifications page. Maybe ignoring suspicious items?

ItamarWMDE renamed this task from Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $title: invalid name to [SW][CLIENT] Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $title: invalid name.Jul 5 2024, 8:59 AM
ItamarWMDE subscribed.

Prio Notes:

Impact AreaAffected
production / end usersyes
monitoringyes
development effortsno
onboarding effortsno
additional stakeholdersno

It seems two problems meet here:

  • On the Wikibase side (in fact, it's me to blame), no assumption is made about whether the user exists locally. Maybe I was too lazy to test it ("It could be an IP, anyway").
  • On the Echo side, it is assumed the agent is either registered (exists locally) or an IP address.

I'm wondering how this "timed bomb" could go unnoticed for so long. Maybe such lengthy usernames are unusual (note that this one is an LTA) and their users are even less likely to connect pages to Wikidata. Maybe something in the "autocreate when the change is propagated from Wikidata" mechanism changed and some assumptions are not valid anymore (race condition?). Maybe they have never been valid.

If we cannot assume the user exists locally, what should be done?

  • Force local autocreation? (How difficult is it?)
  • Insert the notification without an agent?
  • Insert no notification?
  • Fix Echo? Echo should definitely throw an exception if it cannot handle the user, but there would still be an error (prior to insertion, so no data corruption).

The status of temporary accounts should also be made clear (this is indeed a good opportunity).

39 characters, a very unusual length

IPv6, I guess (at most 32 bytes + 7 colons = 39).

If we cannot assume the user exists locally, what should be done?

Or some interwiki pointing. The action is done using account on external wiki, so that account should be linked anyway. To be handled by CentralAuth and their hooks?

If we cannot assume the user exists locally, what should be done?

Or some interwiki pointing. The action is done using account on external wiki, so that account should be linked anyway. To be handled by CentralAuth and their hooks?

That's actually what Wikibase does when it inserts recent changes. (So I am striking what I wrote.) But there is still that one problem:

event_agent_ip field is 39 bytes

If we cannot assume the user exists locally, what should be done?

Or some interwiki pointing. The action is done using account on external wiki, so that account should be linked anyway. To be handled by CentralAuth and their hooks?

That's actually what Wikibase does when it inserts recent changes. (So I am striking what I wrote.)

Yes, but not for Echo.

Striked part is for something else.

But there is still that one problem:

event_agent_ip field is 39 bytes

No, this is not problem. It is valid behavoiour.. As you pointed above, it is longest length of IP address. Extension assumed this account is IP because it doesn't exist - this is the real problem.

matej_suchanek changed the task status from Open to In Progress.Aug 25 2024, 9:31 AM
matej_suchanek claimed this task.

You are right. The root problem is we let it insert a nonexisting user as an IP address. And it needs to be fixed.
It cannot be fixed using "interwiki pointing" you mention, though. Because "interwiki pointing" would not create the user, either.

Change #1065754 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/extensions/Wikibase@master] Do not set the event agent if it doesn't exist locally

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

Change #1065876 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/extensions/Echo@master] Disallow anonymous non-IP agents, handle truncated names

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

ItamarWMDE renamed this task from [SW][CLIENT] Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $title: invalid name to [CLIENT] Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $title: invalid name.Oct 9 2024, 1:58 PM
ItamarWMDE moved this task from Incoming to Unified DOT Backlog on the Wikidata Dev Team board.

moved back to task breakdown as current status of the ticket/ acceptance criteria is unclear

Change #1065754 merged by jenkins-bot:

[mediawiki/extensions/Wikibase@master] Do not set the event agent if it doesn't exist locally

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

Note that to prevent the fatals (original report), the other patch for Echo is also needed. But that may be out of scope for Wikibase people.

Change #1065876 merged by jenkins-bot:

[mediawiki/extensions/Echo@master] Disallow anonymous non-IP agents, handle truncated names

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

Anything left to do here?

I don't think so (on the technical level). I do not know what QA or communications is maybe planned from the Wikidata/WMDE side.

Bigger picture, I would really like for the database to fail loudly when one tries to insert a string that is too long, or filter by a number from a column that contains strings or something like that. But that is out of scope of this task.

Perhaps @tarlocesilion can tell if they can access all their notifications again.

Possible follow-ups:

I would really like for the database to fail loudly when one tries to insert a string that is too long

I believe T108255: Enable MariaDB/MySQL's Strict Mode would cover that.