Page MenuHomePhabricator

Special:WantedCategories on eswiki - "Fatal exception of type "Wikimedia\Assert\ParameterAssertionException""
Closed, ResolvedPublic

Description

https://es.wikipedia.org/wiki/Especial:Categor%C3%ADasRequeridas (Special:WantedCategories) returns a fatal exception with a text similar to:

[V@qQggpAAEIAADi6SMoAAABC] 2016-09-27 15:30:10: Excepción grave de tipo "Wikimedia\Assert\ParameterAssertionException"

Looks like the error only happens in the Spanish language Wikipedia.

Event Timeline

dgstranz created this task.Sep 27 2016, 3:42 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 27 2016, 3:42 PM
2016-09-27 15:30:10 [V@qQggpAAEIAADi6SMoAAABC] mw1271 eswiki 1.28.0-wmf.20 exception ERROR: [V@qQggpAAEIAADi6SMoAAABC] /wiki/Especial:Categor%C3%ADasRequeridas   Wikimedia\Assert\ParameterAssertionException from line 63 of /srv/mediawiki/php-1.28.0-wmf.20/vendor/wikimedia/assert/src/Assert.php: Bad value for parameter $dbkey: invalid DB key {"exception_id":"V@qQggpAAEIAADi6SMoAAABC"} 
[Exception Wikimedia\Assert\ParameterAssertionException] (/srv/mediawiki/php-1.28.0-wmf.20/vendor/wikimedia/assert/src/Assert.php:63) Bad value for parameter $dbkey: invalid DB key
  #0 /srv/mediawiki/php-1.28.0-wmf.20/includes/title/TitleValue.php(81): Wikimedia\Assert\Assert::parameter(boolean, string, string)
  #1 /srv/mediawiki/php-1.28.0-wmf.20/includes/cache/LinkBatch.php(175): TitleValue->__construct(integer, string)
  #2 /srv/mediawiki/php-1.28.0-wmf.20/includes/cache/LinkBatch.php(139): LinkBatch->addResultToCache(LinkCache, ResultWrapper)
  #3 /srv/mediawiki/php-1.28.0-wmf.20/includes/cache/LinkBatch.php(126): LinkBatch->executeInto(LinkCache)
  #4 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/WantedQueryPage.php(52): LinkBatch->execute()
  #5 /srv/mediawiki/php-1.28.0-wmf.20/includes/specials/SpecialWantedcategories.php(55): WantedQueryPage->preprocessResults(DatabaseMysqli, ResultWrapper)
  #6 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/QueryPage.php(613): WantedCategoriesPage->preprocessResults(DatabaseMysqli, ResultWrapper)
  #7 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/SpecialPage.php(522): QueryPage->execute(NULL)
  #8 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/SpecialPageFactory.php(584): SpecialPage->run(NULL)
  #9 /srv/mediawiki/php-1.28.0-wmf.20/includes/MediaWiki.php(283): SpecialPageFactory::executePath(Title, RequestContext)
  #10 /srv/mediawiki/php-1.28.0-wmf.20/includes/MediaWiki.php(861): MediaWiki->performRequest()
  #11 /srv/mediawiki/php-1.28.0-wmf.20/includes/MediaWiki.php(522): MediaWiki->main()
  #12 /srv/mediawiki/php-1.28.0-wmf.20/index.php(43): MediaWiki->run()
  #13 /srv/mediawiki/w/index.php(3): include(string)
  #14 {main}
bd808 added a subscriber: bd808.Sep 27 2016, 3:49 PM
2016-09-27 15:30:10 [V@qQggpAAEIAADi6SMoAAABC] mw1271 eswiki 1.28.0-wmf.20 exception ERROR: [V@qQggpAAEIAADi6SMoAAABC] /wiki/Especial:Categor%C3%ADasRequeridas   Wikimedia\Assert\ParameterAssertionException from line 63 of /srv/mediawiki/php-1.28.0-wmf.20/vendor/wikimedia/assert/src/Assert.php: Bad value for parameter $dbkey: invalid DB key {"exception_id":"V@qQggpAAEIAADi6SMoAAABC"}
[Exception Wikimedia\Assert\ParameterAssertionException] (/srv/mediawiki/php-1.28.0-wmf.20/vendor/wikimedia/assert/src/Assert.php:63) Bad value for parameter $dbkey: invalid DB key
  #0 /srv/mediawiki/php-1.28.0-wmf.20/includes/title/TitleValue.php(81): Wikimedia\Assert\Assert::parameter(boolean, string, string)
  #1 /srv/mediawiki/php-1.28.0-wmf.20/includes/cache/LinkBatch.php(175): TitleValue->__construct(integer, string)
  #2 /srv/mediawiki/php-1.28.0-wmf.20/includes/cache/LinkBatch.php(139): LinkBatch->addResultToCache(LinkCache, ResultWrapper)
  #3 /srv/mediawiki/php-1.28.0-wmf.20/includes/cache/LinkBatch.php(126): LinkBatch->executeInto(LinkCache)
  #4 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/WantedQueryPage.php(52): LinkBatch->execute()
  #5 /srv/mediawiki/php-1.28.0-wmf.20/includes/specials/SpecialWantedcategories.php(55): WantedQueryPage->preprocessResults(DatabaseMysqli, ResultWrapper)
  #6 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/QueryPage.php(613): WantedCategoriesPage->preprocessResults(DatabaseMysqli, ResultWrapper)
  #7 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/SpecialPage.php(522): QueryPage->execute(NULL)
  #8 /srv/mediawiki/php-1.28.0-wmf.20/includes/specialpage/SpecialPageFactory.php(584): SpecialPage->run(NULL)
  #9 /srv/mediawiki/php-1.28.0-wmf.20/includes/MediaWiki.php(283): SpecialPageFactory::executePath(Title, RequestContext)
  #10 /srv/mediawiki/php-1.28.0-wmf.20/includes/MediaWiki.php(861): MediaWiki->performRequest()
  #11 /srv/mediawiki/php-1.28.0-wmf.20/includes/MediaWiki.php(522): MediaWiki->main()
  #12 /srv/mediawiki/php-1.28.0-wmf.20/index.php(43): MediaWiki->run()
  #13 /srv/mediawiki/w/index.php(3): include(string)
  #14 {main}
abian added a subscriber: abian.Sep 27 2016, 4:31 PM
abian added a comment.Sep 27 2016, 4:50 PM

I've checked out all the Wikipedias, one by one, and yes, only the Spanish Wikipedia is showing an internal error for its Special:WantedCategories.

-jem- added a subscriber: -jem-.Sep 27 2016, 5:06 PM
greg added a subscriber: greg.Sep 28 2016, 11:09 PM
Florian added a subscriber: Florian.
TTO added a subscriber: TTO.Dec 31 2016, 5:02 AM
MariaDB [eswiki_p]> SELECT /* WantedCategoriesPage::reallyDoQuery TTO */ 14 AS `namespace`,cl_to AS `title`,COUNT(*) AS `value` FROM `categorylinks` LEFT JOIN `page` ON ((page_title = cl_to) AND page_namespace = '14') WHERE (page_title IS NULL) GROUP BY cl_to ORDER BY value DESC LIMIT 51;
+-----------+------------------------------------------------------------------------+-------+
| namespace | title                                                                  | value |
+-----------+------------------------------------------------------------------------+-------+
|        14 | Doctores_honorarios_de_la_Universidad_de_Tel_Aviv                      |   125 |
|        14 | Orden_del_Imperio_británico                                            |    83 |
|        14 | Ethnic_and_religious_slurs                                             |    56 |
|        14 | Refugees_by_type                                                       |    56 |
|        14 | Forced_migration                                                       |    53 |
|        14 | Human_migration                                                        |    53 |
|        14 | Persecution                                                            |    53 |
|        14 | Homelessness                                                           |    53 |
|        14 | Wikipedia:Artículos_que_usan_la_plantilla_copa_con_espacios_en_blanco  |    33 |
|        14 | Segundo_Editatón_WikiUNAM/A._Nuevos                                    |    33 |
|        14 | Series_de_televisión_por_año_de_emisión_original                       |    31 |
|        14 | Objetos_astronómicos_descubiertos_por_Louis_Boyer                      |    31 |
|        14 | Wikipedia:Miembros_del_Wikiproyecto_Religión                           |    31 |
|        14 | Futbolistas_de_los_Cafetaleros_de_Tapachula                            |    23 |
|        14 | Articles_containing_Japanese-language_text                             |    20 |
|        14 | Wikipedia:Miembros_del_Wikiproyecto_Budismo                            |    18 |
|        14 | Romí                                                                   |    14 |
|        14 | Wikipedia:Miembros_del_Wikiproyecto_Semana_Santa                       |    14 |
|        14 | Stan_Wawrinka                                                          |    13 |
|        14 | Medallistas_paralímpicos_de_bronce_de_España                           |    13 |
|        14 | Wikipedia:Wikipedistas_con_conocimientos_de_                           |    12 |
|        14 | Gitanas                                                                |    12 |
|        14 | Medallistas_paralímpicos_de_plata_de_España                            |    12 |
|        14 | Rrom                                                                   |    11 |
|        14 | Películas_de_Universal_Pictures_Home_Entertainment                     |    11 |
|        14 | Wikipedia:Miembros_del_Wikiproyecto_Jesús_de_Nazaret                   |    11 |
|        14 | Campeonato_Mundial_de_Supersport                                       |    11 |
|        14 | Arquitectura_de_México_del_siglo_XX                                    |    10 |
|        14 | Lucha_en_los_años_1950                                                 |    10 |
|        14 | Lucha_en_los_años_1960                                                 |    10 |
|        14 | Lucha_en_los_años_1970                                                 |    10 |
|        14 | Series_de_televisión_de_2011                                           |    10 |
|        14 | Escritores_de_Vitoria                                                  |     9 |
|        14 | Series_de_televisión_de_2010                                           |     9 |
|        14 | Copas_Panamericanas_Bajo_Techo_de_Hockey                               |     8 |
|        14 | Años_1570_en_Nueva_España                                              |     7 |
|        14 | Gitanos_de_España                                                      |     7 |
|        14 | Años_1760_en_Nueva_España                                              |     7 |
|        14 | Series_de_televisión_emitidas_originalmente_en_2013                    |     7 |
|        14 | Grandes_Premios_de_motociclismo_2013                                   |     7 |
|        14 | Competiciones_de_motociclismo_de_Gran_Bretaña                          |     7 |
|        14 | Tampichthys                                                            |     6 |
|        14 | Años_1730_en_Nueva_España                                              |     6 |
|        14 | Álbumes_de_post-punk                                                   |     6 |
|        14 | Poetas_brumosos                                                        |     6 |
|        14 | Nadadores_de_España_en_los_Juegos_Paralímpicos_de_Pekín_2008           |     6 |
|        14 | Años_1770_en_Nueva_España                                              |     6 |
|        14 | All_articles_with_unsourced_statements                                 |     6 |
|        14 | Musica                                                                 |     6 |
|        14 | Programa_Internacional_de_Escritura                                    |     6 |
|        14 | Películas_dirigidas_por_Yasuichiro_Yamamoto                            |     6 |
+-----------+------------------------------------------------------------------------+-------+
51 rows in set (10.74 sec)

Hmm... the trailing underscore in Category:Wikipedia:Wikipedistas_con_conocimientos_de_ looks a bit suspicious. And sure enough:

$ php maintenance/eval.php
> new TitleValue( 14, 'Wikipedia:Wikipedistas_con_conocimientos_de_' )
Caught exception Wikimedia\Assert\ParameterAssertionException: Bad value for parameter $dbkey: invalid DB key
#0 /mnt/c/Users/TTO/Documents/Programming/MediaWiki/core/includes/title/TitleValue.php(81): Wikimedia\Assert\Assert::parameter(false, '$dbkey', 'invalid DB key')
#1 /mnt/c/Users/TTO/Documents/Programming/MediaWiki/core/maintenance/eval.php(77) : eval()'d code(1): TitleValue->__construct(14, 'Wikipedia:Wikip...')
#2 /mnt/c/Users/TTO/Documents/Programming/MediaWiki/core/maintenance/eval.php(77): eval()
#3 {main}
>

There are twelve user pages in that category:

MariaDB [eswiki_p]> select page_namespace, page_title from categorylinks inner join page on cl_from=page_id where cl_to='Wikipedia:Wikipedistas_con_conocimientos_de_';
+----------------+--------------------------------+
| page_namespace | page_title                     |
+----------------+--------------------------------+
|              2 | Dennis6492                     |
|              2 | Pablodiego15                   |
|              2 | Harvert_Vanegas/Zona_de_prueba |
|              2 | Harvert_Vanegas                |
|              2 | Harvert                        |
|              2 | SubSevenMoRpHeEuS              |
|              2 | Gustavob                       |
|              2 | Labant                         |
|              2 | Gustavo_gho                    |
|              2 | DidiSparksFer                  |
|              2 | Lein03                         |
|              2 | Anfergon                       |
+----------------+--------------------------------+
12 rows in set (0.01 sec)

But you can't browse to them: https://es.wikipedia.org/wiki/Usuario:Dennis6492 gives [WGc59wpAADwAABMl5i0AAAAE] 2016-12-31 04:54:15: Excepción grave de tipo "Wikimedia\Assert\ParameterAssertionException"

There are several categorylinks rows in the eswiki DB that are broken like this:

MariaDB [eswiki_p]> select cl_to,count(cl_to) from categorylinks where cl_to like '%\_' group by cl_to;
+--------------------------------------------------+--------------+
| cl_to                                            | count(cl_to) |
+--------------------------------------------------+--------------+
| Wikipedia:Wikipedistas_con_conocimientos_de_     |           12 |
| Wikipedia:Wikipedistas_con_nivel_avanzado_de_    |            1 |
| Wikipedia:Wikipedistas_con_nivel_básico_de_      |            5 |
| Wikipedia:Wikipedistas_con_nivel_nativo_de_      |            3 |
| Wikipedia:Wikipedistas_con_nivel_profesional_de_ |            3 |
+--------------------------------------------------+--------------+
5 rows in set (4.39 sec)

None on enwiki:

MariaDB [enwiki_p]> select cl_to,count(cl_to) from categorylinks where cl_to like '%\_' group by cl_to;
Empty set (1 min 53.84 sec)

Actionables here:

  • Manually delete the broken categorylinks rows from the DB: DELETE FROM categorylinks WHERE cl_to LIKE '%\_';
  • Investigate where these are coming from
  • Change TitleValue's constructor so it puts the actual invalid DB key in the error message. That would have helped a lot...

The immediate cause is the Babel call {{#babel:pt-br-1}}.

The problem seems to be that LanguageBabelBox::getCategoryName calls Title::makeTitle, which does no validation, instead of Title::makeTitleSafe. This allows the invalid DB key to get through to the keeper, so to speak.

The bug can be reproduced by setting $wgBabelCategoryNames = ['1' => 'Wikiname is %wikiname%']; in your LocalSettings

Change 329733 had a related patch set uploaded (by TTO):
Correct categorization of 'pt-br' and similar language codes

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

Change 329734 had a related patch set uploaded (by TTO):
TitleValue: Include the invalid DB key in the message when throwing

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

TTO added a comment.Dec 31 2016, 6:06 AM

Once the Babel patch is merged and deployed, a null edit of those user pages will fix the problem. eswiki appears to be the only affected wiki, and the 12 pages listed above are the only ones affected.

Change 329734 merged by jenkins-bot:
TitleValue: Include the invalid DB key in the message when throwing

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

Change 329733 merged by jenkins-bot:
Correct categorization of 'pt-br' and similar language codes

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

TTO added a comment.Jan 9 2017, 3:03 PM

I can confirm that the twelve user pages are now accessible. However, WantedCategories is still not working, even after I null-edited the user pages.

The bogus categorylinks are gone from the DB:

MariaDB [eswiki_p]> select cl_to,count(cl_to) from categorylinks where cl_to like '%\_' group by cl_to;
Empty set (5.98 sec)

So I suppose it's a matter of waiting for the query cache to be updated.

TTO closed this task as Resolved.Jan 22 2017, 8:17 AM
TTO claimed this task.

Fixed now.