Page MenuHomePhabricator

VisualEditor: Throws error when trying to edit blank (but existing) page
Closed, ResolvedPublic

Description

I created a blank page at https://www.mediawiki.org/wiki/VisualEditor:Hello_there. When I try to edit the page using the VisualEditor extension, I receive the following error: "Error loading data from server: No HTML content in response from server. Would you like to retry?"

I imagine this is a safety check somewhere in the code that needs to be tweaked. If page_len == 0, it isn't always an error. Sometimes a blank page is just a blank page. ;-)


Version: unspecified
Severity: normal

Details

Reference
bz37843

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:30 AM
bzimport set Reference to bz37843.

That blank page shouldn't have been possible to create in the first place.

(In reply to comment #1)

That blank page shouldn't have been possible to create in the first place.

Heh, well I originally created the page as the brand new account I was using to test VisualEditor didn't have the createpage right (for whatever reason).

To be clear, this bug is not about VisualEditor creating a blank page. This bug is about VisualEditor throwing an error when the page length is 0 bytes and the user attempts to edit the page using the VisualEditor interface. https://www.mediawiki.org/wiki/VisualEditor:Blank_page is another test case.

For discussion regarding whether MediaWiki should allow users to create blank pages, you want bug 12621. :-)

Mass-moving items into VisualEditor product

Parsoid does handle zero length content -- it returns a zero length HTML response. Right now, VisualEditor extension expects a non-zero HTML response and returns an error if not (line 18 of ApiVisualEditor.php). This can be verified at this url: https://www.mediawiki.org/w/api.php?action=ve-parsoid&paction=parse&page=VisualEditor%3AHello_there&format=json (for other pages, the result is success with a valid parsed string). So, either ApiVisualEditor.php has to handle a zero-length response as a valid response, and we need a different way to signal errors from Parsoid, or Parsoid has to always return a non-zero response. My hunch is that as long as Parsoid returns a 200 OK, ApiVisualEditor accept a zero-length response as a valid response (and if necessary, have sanity checks somewhere -- a non-zero length body should not return a zero-length response, maybe). Error conditions from Parsoid could be signaled with a different HTTP response code maybe (offhand, 503 is one option). At this time, I am not sure what the right solution is, but hopefully this will help figure out what that might be.

Actually, I meant 500, not 503.

Moving to DM if we're happy with current Parsoid behaviour - to discuss?

(In reply to comment #1)

That blank page shouldn't have been possible to create in the first place.

You can easily create a blank page by first creating a page with content, then blanking it.

(In reply to comment #4)

Parsoid does handle zero length content -- it returns a zero length HTML
response. Right now, VisualEditor extension expects a non-zero HTML response
and returns an error if not (line 18 of ApiVisualEditor.php). This can be
verified at this url:
https://www.mediawiki.org/w/api.php?action=ve-parsoid&paction=parse&page=VisualEditor%3AHello_there&format=json
(for other pages, the result is success with a valid parsed string).

Thanks Subbu, that's exactly what was going on. Fix submitted in https://gerrit.wikimedia.org/r/30281 .

So,
either ApiVisualEditor.php has to handle a zero-length response as a valid
response, and we need a different way to signal errors from Parsoid, or Parsoid
has to always return a non-zero response. My hunch is that as long as Parsoid
returns a 200 OK, ApiVisualEditor accept a zero-length response as a valid
response (and if necessary, have sanity checks somewhere -- a non-zero length
body should not return a zero-length response, maybe). Error conditions from
Parsoid could be signaled with a different HTTP response code maybe (offhand,
503 is one option). At this time, I am not sure what the right solution is, but
hopefully this will help figure out what that might be.

I verified that nonexistent pages give me a 404, so I think this is fine. I haven't checked other error conditions because they're nontrivial to reproduce, but as long as Parsoid only returns a 2xx status code when it's actually delivering parsed content and uses 4xx/5xx for errors, I'll be fine.

Resolved in gerrit.

Change-Id: I8857d39e1a20080c8419c6165be2b5ad0cdbacd2