Page MenuHomePhabricator

Scribunto fails with confusing error message for invalid #interlanguagelink langcode
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Evaluate in the Lua console: mw.getCurrentFrame():callParserFunction("#interlanguagelink",{"fff","foo"})

What happens?:

It produced Lua error: callParserFunction: function "#interlanguagelink" was not found.

What should have happened instead?:

It should give a more accurate error message like Invalid language code fff

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

This parser function was recently introduced in T363538

Event Timeline

Ammarpad subscribed.

It's not limited to this particular parser function and the problem did exist before its introduction.

It seems the same reponse format from the parser is used for 'invalid input' and 'function not found' cases, and so Scribunto has no way of differentiating these.

Change #1134081 had a related patch set uploaded (by Pppery; author: Pppery):

[mediawiki/extensions/Scribunto@master] Make bad parser function error more generic

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

It's not limited to this particular parser function and the problem did exist before its introduction.

It seems the same reponse format from the parser is used for 'invalid input' and 'function not found' cases, and so Scribunto has no way of differentiating these.

The documentation for Parser::callParserFunction says: "The returned array will always contain a boolean 'found', indicating whether the parser function was found or not." So why shouldn't the core parser functions be fixed to return something else?

How about on changing the error message to include the first arg:

Lua error: callParserFunction: function "#interlanguagelink:fff" was not found.

The problem here is the developers of #interlanguagelink seem to have treated that as one unit which isn't found, whereas the Scribunto extension separates them in a way not possible in wikitext.