Page MenuHomePhabricator

VisualEditor fails when switching back-and-forth between visual and wikitext modes on a third-party wiki
Open, Needs TriagePublic

Description

VisualEditor is failing to request RESTbase to convert HTML to Wikitext.
This is what was outputed in RESTbase's logs.

{"name":"restbase","hostname":"UBUNTU","pid":10565,"level":40,"msg":"Client did not supply etag, fallback to mw:TimeUuid meta element","root_req":{"method":"post","uri":"/wiki.therofl98.co/v1/transform/html/to/wikitext/User%3ATherofl98%2Fsandbox/2698","headers":{"content-length":"3865","content-type":"multipart/form-data; boundary=------------------------5ae5598f4d8291f0","if-match":"null","user-agent":"VisualEditor-MediaWiki/1.33.0-alpha","api-user-agent":"VisualEditor-MediaWiki/1.33.0-alpha","x-client-ip":"::ffff:127.0.0.1","x-forwarded-for":"2601:241:4101:6b97:d958:12de:3ce0:3c49, ::ffff:127.0.0.1","x-request-id":"c793ac00-41e9-11e9-95ba-97b55f560dd8","x-request-class":"internal"}},"request_id":"c793ac00-41e9-11e9-95ba-97b55f560dd8","api_path":"/wiki.therofl98.co/v1/transform/html/to/wikitext{/title}{/revision}","levelPath":"warn/parsoid/etag","time":"2019-03-08T21:33:14.317Z","v":0}

I'm assuming the error is because VisualEditor didn't supply an etag, making it fail.

Event Timeline

Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptMar 18 2019, 3:45 PM
mobrovac added a subscriber: mobrovac.

When RESTBase encounters this problem, it doesn't fail, as the log message suggests, there is a fallback that checks the HTML to find the actual ETag.

@TheROFL98 Please can you provide specific steps to reproduce? The specific HTML that you were trying to paste would be helpful, at a minimum.

I'm having this problem on a self hosted MediaWiki installation, located here. To reproduce, you begin editing a page in VisualEditor. You make some edits on the page, but don't save it just yet. You switch to the Wikitext editor to see how that version looks, and make adjustments. You then switch back to Visual to see how it looks, and make further adjustments. After this, when you try to switch to Wikitext, Error loading data from server: apierror-visualeditor-docserver-http. pops up, and the RESTbase log reports something similar to this:

{"name":"restbase","hostname":"UBUNTU","pid":10565,"level":40,"msg":"Client did not supply etag, fallback to mw:TimeUuid meta element","root_req":{"method":"post","uri":"/wiki.therofl98.co/v1/transform/html/to/wikitext/User%3ATherofl98%2Fsandbox/2698","headers":{"content-length":"3865","content-type":"multipart/form-data; boundary=------------------------5ae5598f4d8291f0","if-match":"null","user-agent":"VisualEditor-MediaWiki/1.33.0-alpha","api-user-agent":"VisualEditor-MediaWiki/1.33.0-alpha","x-client-ip":"::ffff:127.0.0.1","x-forwarded-for":"2601:241:4101:6b97:d958:12de:3ce0:3c49, ::ffff:127.0.0.1","x-request-id":"c793ac00-41e9-11e9-95ba-97b55f560dd8","x-request-class":"internal"}},"request_id":"c793ac00-41e9-11e9-95ba-97b55f560dd8","api_path":"/wiki.therofl98.co/v1/transform/html/to/wikitext{/title}{/revision}","levelPath":"warn/parsoid/etag","time":"2019-03-08T21:33:14.317Z","v":0}

If you wish to reproduce this, account creation is required. I apologize for that, as the community that helps me run it chose to require account creation.

Deskana renamed this task from VisualEditor won't convert HTML to Wikitext to VisualEditor fails when switching back-and-forth between visual and wikitext modes on a third-party wiki.Mar 19 2019, 10:52 AM

I see. So, this isn't about pasting HTML into the VisualEditor and having it convert it to wikitext, it's about the conversion done when you're switching back-and-forth between the visual and wikitext modes. I've retitled the bug. Prioritisation is up to the Editing team, I'm just a volunteer trying to help clarify bugs. :-)

I've checked the RESTbase Docs in https://wiki.therofl98.co/api/rest_v1/ and tested conversion from HTML to Wikitext. When I input HTML, page title, and revision, it returns a 400 with a message similar to

{
  "type": "https://mediawiki.org/wiki/HyperSwitch/errors/bad_request",
  "method": "post",
  "detail": "No or invalid If-Match header supplied, or missing mw:TimeUuid meta element in the supplied HTML.",
  "uri": "/wiki.therofl98.co/v1/transform/html/to/wikitext/test/1"
}
JTannerWMF moved this task from To Triage to Freezer on the VisualEditor board.Mar 27 2019, 6:29 PM