Page MenuHomePhabricator

"Math extension cannot connect to Restbase."
Open, Needs TriagePublic

Description

The following error is displayed instead of the rendered formula:

Failed to parse (MathML with SVG or PNG fallback (recommended for modern browsers and accessibility tools): Invalid response ("Math extension cannot connect to Restbase.") from server "https://en.wikipedia.org/api/rest_v1/":): {\displaystyle x = 123}

Occasionally, a formula is rendered successfully. But once I modify the formula (for example in VisualEditor), this error occurs again.

I am on MediaWiki 1.35.0, freshly installed as a Bitnami VM application on my local machine. The only extensions I have are VisualEditor 0.1.2 and Math 3.0.0 (b5a8f57).

Special:MathStatus

The following error is shown on the Special:MathStatus page (the hash changes when I refresh the page):

[77976fdf607ace02e33b7313] /wiki/Special:MathStatus MWException from line 109 of /bitnami/mediawiki/extensions/Math/src/MathRestbaseInterface.php: TeX input is invalid.

Backtrace:

#0 /bitnami/mediawiki/extensions/Math/src/MathRestbaseInterface.php(426): MathRestbaseInterface->calculateHash()
#1 /bitnami/mediawiki/extensions/Math/src/MathRestbaseInterface.php(100): MathRestbaseInterface->getContentRequest(string)
#2 /bitnami/mediawiki/extensions/Math/src/MathRestbaseInterface.php(232): MathRestbaseInterface->getContent(string)
#3 /bitnami/mediawiki/extensions/Math/src/MathRenderer.php(685): MathRestbaseInterface->getSvg()
#4 /bitnami/mediawiki/extensions/Math/src/MathMathML.php(405): MathRenderer->getSvg()
#5 /bitnami/mediawiki/extensions/Math/src/MathMathML.php(446): MathMathML->correctSvgStyle(NULL)
#6 /bitnami/mediawiki/extensions/Math/src/MathMathML.php(525): MathMathML->getFallbackImage()
#7 /bitnami/mediawiki/extensions/Math/src/SpecialMathStatus.php(69): MathMathML->getHtmlOutput()
#8 /bitnami/mediawiki/extensions/Math/src/SpecialMathStatus.php(51): SpecialMathStatus->testSpecialCaseText()
#9 /bitnami/mediawiki/extensions/Math/src/SpecialMathStatus.php(41): SpecialMathStatus->runMathMLTest(string)
#10 /opt/bitnami/mediawiki/includes/specialpage/SpecialPage.php(600): SpecialMathStatus->execute(NULL)
#11 /opt/bitnami/mediawiki/includes/specialpage/SpecialPageFactory.php(635): SpecialPage->run(NULL)
#12 /opt/bitnami/mediawiki/includes/MediaWiki.php(307): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)
#13 /opt/bitnami/mediawiki/includes/MediaWiki.php(940): MediaWiki->performRequest()
#14 /opt/bitnami/mediawiki/includes/MediaWiki.php(543): MediaWiki->main()
#15 /opt/bitnami/mediawiki/index.php(53): MediaWiki->run()
#16 /opt/bitnami/mediawiki/index.php(46): wfIndexMain()
#17 {main}

Occasionally, the error does not occur, and instead I see a list of tests, with one failed test called Comparing the generated SVG with the reference.

What I've tried

  • I disabled the firewall of my Mac (that is the host of the Bitnami VM), and tried setting $wgMathFullRestbaseURL= 'https://en.wikipedia.org/api/rest_' in LocalSettings.php. I also tried changing my Internet connection.
  • I tried disabling the VisualEditor extension. I also tried restarting the Apache server and the entire Bitnami VM.
  • I read this post but found the problem is already fixed in my version of MultiHttpClient.php.

Event Timeline

Hi, which [https://www.mediawiki.org/wiki/Extension:Math#Math_output_modes](output mode) is set; what are the values for all Math related settings, plus the value for $wgMathEnableExperimentalInputFormats ?

Thanks for your reply. I believe all Math-related settings are left in their default, except that I tried setting $wgMathFullRestbaseURL = 'https://en.wikipedia.org/api/rest_' (which didn't help).

  • The error persists if I set $wgDefaultUserOptions['math'] = 'mathml' or 'png'. However, if I set it to 'source', there is no error (because no API call is needed to render the formula).
  • I did not set $wgMathEnableExperimentalInputFormats, but it seems to have no impact on the result as I toggle it now.

The fact that occasionally a formula is rendered successfully is odd. It's often the first formula that I tried in a while that gets rendered successfully, and all subsequent formulae fail to render. (It behaves like a very strong throttling that only allows 1 formula every 10 minutes or so.)

I think the message should be modified. This is not a very friendly message. Especially with that "localhost" which might freak out a dev 😉 (my initial thought: why is Wikipedia trying to connect to my localhost). Jokes aside, the message does suggest there is problem on my side but – as I understand – this is mostly a backend problem. So maybe log some details to JS console or a tooltip or something...

GUI should be simple, so I think what should happen is:

  1. Keep last good image if available.
  2. Below/near the image say something like "image is stale, internal error" ← maybe add a title attribute (tooltip) to this.
  3. If retry is possible then add a retry button.

Or if the problem is actually with syntax then just say "image is stale, syntax error" (if possible add "at line X" / "at character Y" / "near this code").

obraz.png (865×980 px, 125 KB)
obraz.png (865×997 px, 79 KB)

PS: I think in this case (on my images above) a more accurate message would be "unrecognized syntax". I think the parser just couldn't handle a dangling coma.

We're consistently getting this error now on nlwiki, but not on all instances. See e.g. radon-220: 2 out of 6 are good (maybe cached?) and 4 give an error like:

Fout bij het parsen (SVG (MathML kan worden gebruikt via een browserplugin): Ongeldig antwoord ("Math extension cannot connect to Restbase.") van server "http://localhost:6011/nl.wikipedia.org/v1/":): {\displaystyle \ce{{^{ 232 }_{90} Th } -> {^{ 228}_{ 88 } Ra } + ^4_2\alpha }}

The TeX code is generated by a template, and the arguments are similar, so it's strange that some are "good" and some "bad".