Page MenuHomePhabricator

Exception from line 1539 of ResourceLoader.php: JSON serialization of config data failed. This usually means the config data is not valid UTF-8.
Closed, ResolvedPublic

Description

2018-11-04 18:19:19 [W984JgpAMFIAABIcGuQAAAAD] mw1247 srwiki 1.33.0-wmf.1 exception ERROR: [W984JgpAMFIAABIcGuQAAAAD] /wiki/%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD:Ping   Exception from line 1539 of /srv/mediawiki/php-1.33.0-wmf.1/includes/resourceloader/ResourceLoader.php: JSON serialization of config data failed. This usually means the config data is not valid UTF-8. {"exception_id":"W984JgpAMFIAABIcGuQAAAAD","exception_url":"/wiki/%D0%A8%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD:Ping","caught_by":"mwe_handler"} 
[Exception Exception] (/srv/mediawiki/php-1.33.0-wmf.1/includes/resourceloader/ResourceLoader.php:1539) JSON serialization of config data failed. This usually means the config data is not valid UTF-8.
  #0 /srv/mediawiki/php-1.33.0-wmf.1/includes/resourceloader/ResourceLoaderClientHtml.php(283): ResourceLoader::makeConfigSetScript(array)
  #1 /srv/mediawiki/php-1.33.0-wmf.1/includes/OutputPage.php(3117): ResourceLoaderClientHtml->getHeadHtml()
  #2 /srv/mediawiki/php-1.33.0-wmf.1/includes/skins/SkinTemplate.php(472): OutputPage->headElement(SkinVector)
  #3 /srv/mediawiki/php-1.33.0-wmf.1/includes/skins/SkinTemplate.php(225): SkinTemplate->prepareQuickTemplate()
  #4 /srv/mediawiki/php-1.33.0-wmf.1/includes/OutputPage.php(2623): SkinTemplate->outputPage()
  #5 /srv/mediawiki/php-1.33.0-wmf.1/includes/MediaWiki.php(867): OutputPage->output(boolean)
  #6 /srv/mediawiki/php-1.33.0-wmf.1/includes/MediaWiki.php(879): Closure$MediaWiki::main()
  #7 /srv/mediawiki/php-1.33.0-wmf.1/includes/MediaWiki.php(517): MediaWiki->main()
  #8 /srv/mediawiki/php-1.33.0-wmf.1/index.php(42): MediaWiki->run()
  #9 /srv/mediawiki/w/index.php(3): include(string)
  #10 {main}

Event Timeline

Reedy created this task.Nov 4 2018, 6:24 PM
Restricted Application added subscribers: Petar.petkovic, Aklapper. · View Herald TranscriptNov 4 2018, 6:24 PM

This exception was added at abd3c02d0811.

Unlike T207876, here the redirect table is not the source of the error:

MariaDB [srwiki_p]> select *, length(rd_fragment) from redirect where length(rd_fragment)>=250 \G
Empty set (1.45 sec)

(Шаблон = Template, Модул = Module)
https://sr.wikipedia.org/wiki/Шаблон:Ping redirects to https://sr.wikipedia.org/wiki/Шаблон:Одговор which invokes https://sr.wikipedia.org/wiki/Модул:Reply_to

The configuration array seems ok at Шаблон:Одговор on edit page. Модул:Reply_to doesn't show any error.

Platonides added a comment.EditedNov 4 2018, 7:22 PM

I have reduced the template text to this failing wikitext:

{{#invoke:Reply to|replyto}}
{{документација}}

Any of those lines work standalone.

Catrope added a subscriber: Catrope.Nov 5 2018, 6:28 PM

The config var that fails to encode is ScribuntoErrors, which is set to:

array(1) { [0]=> string(1256) "

Lua грешка in Модул:Reply_to at line 30: invalid option '%�' to 'format'.

Backtrace:

    [C]: in function "format"
    Модул:Reply_to:30: in function "chunk"
    mw.lua:511: ?
    [C]: ?
    [C]: in function "getExpandedArgument"
    mw.lua:169: ?
    Модул:Arguments:254: ?
    Модул:Documentation:647: in function "_content"
    Модул:Documentation:140: ?
    (tail call): ?
    mw.lua:511: ?
    [C]: ?

" }

As you can probably see, the invalid option '%�' to 'format' part is where the invalid UTF-8 character is.

I don't know why this would lead to a UTF-8 encoding error necessarily, but I looked at line 30 and this doesn't look valid to me:

	if usernames > (tonumber(frame.args.max) or 50) then
		return makeError(string.format(
			'Више од % назначених имена.',
			tostring(frame.args.max or 50)
		))

Looks like this was %s until the s was accidentally deleted in this edit. I put it back and that unbroke it.

It seems there may be a bug in Scribunto or Lua where trying to use % н in a format string causes a misformatted error, but we'll have to dig deeper to track that down.

Krinkle added a subscriber: Krinkle.

Recent trace:

[XA-8HApAAD4AAJI9rwUAAAAQ] Exception: JSON serialization of config data failed. This usually means the config data is not valid UTF-8.

POST tt.wikipedia.org  /w/index.php?title=Module:Infocards&action=submit

#0 /srv/mediawiki/php-1.33.0-wmf.6/includes/resourceloader/ResourceLoaderClientHtml.php(283): ResourceLoader::makeConfigSetScript(array)
#1 /srv/mediawiki/php-1.33.0-wmf.6/includes/OutputPage.php(3208): ResourceLoaderClientHtml->getHeadHtml()
#2 /srv/mediawiki/php-1.33.0-wmf.6/includes/skins/SkinTemplate.php(472): OutputPage->headElement(SkinVector)
#3 /srv/mediawiki/php-1.33.0-wmf.6/includes/skins/SkinTemplate.php(225): SkinTemplate->prepareQuickTemplate()
#4 /srv/mediawiki/php-1.33.0-wmf.6/includes/OutputPage.php(2714): SkinTemplate->outputPage()
#5 /srv/mediawiki/php-1.33.0-wmf.6/includes/MediaWiki.php(869): OutputPage->output(boolean)
#6 /srv/mediawiki/php-1.33.0-wmf.6/includes/MediaWiki.php(881): Closure$MediaWiki::main()
#7 /srv/mediawiki/php-1.33.0-wmf.6/includes/MediaWiki.php(517): MediaWiki->main()
#8 /srv/mediawiki/php-1.33.0-wmf.6/index.php(42): MediaWiki->run()
#9 /srv/mediawiki/w/index.php(3): include(string)
#10 {main}

Breakdown in last 30 days:

ml.wikipedia.org104
my.wikipedia.org60
ru.wikipedia.org5
tt.wikipedia.org5
ur.wikipedia.org4
be-tarask.wikipedia.org3
Krinkle added subscribers: tstarling, Anomie.

Tagging Editing-team and CC-ing Tim and Anomie, per mw:Maintainers for Scribunto.

There's no bug in LuaSandbox here, any more than there's a bug in PHP because sprintf( "Више од % назначених имена.", "baz" ) produces non-UTF-8 output.

It wouldn't hurt to run the message through UtfNormal\Validator::cleanUp() when Scribunto is generating that exception, though, since the rest of MediaWiki probably assumes UTF-8.

Change 479033 had a related patch set uploaded (by Anomie; owner: Anomie):
[mediawiki/extensions/Scribunto@master] Scribunto_LuaError: Make ->getMessage() return UTF-8 text

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

Change 479033 merged by jenkins-bot:
[mediawiki/extensions/Scribunto@master] Scribunto_LuaError: Make ->getMessage() return UTF-8 text

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

Anomie closed this task as Resolved.Dec 12 2018, 3:50 PM
Anomie claimed this task.

This seems likely to be resolved now, both from @Catrope fixing the cause of the specific instance on-wiki and me adjusting Scribunto to UTF-8-normalize error messages in the future.