Page MenuHomePhabricator

Unable to load partial translation due to JS error from ext.cx.tools.template.js
Closed, ResolvedPublic

Description

When I try to load a translation from
https://pt.wikipedia.org/wiki/Special:ContentTranslation?page=Puiseux+series&from=en&to=pt&targettitle=S%C3%A9ries+de+Puiseux
I get

VM161:75 Uncaught TypeError: Cannot read property 'length' of undefined
  at Template.init (<anonymous>:75:6128)
  at new Template (<anonymous>:75:5649)
  at Object.TemplateTool.static.processTemplate (<anonymous>:94:68)
  at TemplateTool.static.processBlockTemplate (<anonymous>:95:944)
  at fire (load.php?debug=false&lang=pt&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:46)
  at Object.fireWith (load.php?debug=false&lang=pt&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:47)
  at Object.fire (load.php?debug=false&lang=pt&modules=jquery%2Cmediawiki|mediawiki.legacy.wikibits&only=scripts&skin=vector&version=1b46sjy:176)
  at ContentTranslationLoader.restoreSection (<anonymous>:8:53)
  at ContentTranslationLoader.restore (<anonymous>:5:74)
  at <anonymous>:3:126

from
https://github.com/wikimedia/mediawiki-extensions-ContentTranslation/blob/37db8e0ebffcc97e5aa9ed41f7b2759b9dcf8f9a/modules/tools/ext.cx.tools.template.js#L71

The problem also happens with Firefox.

Event Timeline

Change 397408 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Guard against js errors for invalid/corrupted(?) templates

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

Change 397408 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Guard against js errors for invalid/corrupted(?) templates

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

Checked in wmf.12 (English to Russian and Spanish translation) - no JS errors were displayed.

I'm still unable to load that partial translation (it shows "Failed to load the saved translation!" at the top). But there is no error info in the console.

@santhosh can you take a look at it?

I re-checked the translation ("Puiseux series" from en to pt in cx-testing and in testwiki for en-catala) - saved partial translation can be loaded without any errors. Also, tried non-ASCII chars in the title - all seems to be fine. Maybe it's the saved translation itself has some unrecoverable errors?