Topic on Extension talk:VisualEditor

Error contacting the Parsoid/RESTBase server (HTTP 404)

12
Summary by Seb35

Reported on phabricator:T261921. Specific to Apache. Solved by adding AllowEncodedSlashes NoDecode in VirtualHost section.

185.69.145.64 (talkcontribs)

Installed Mediawiki 1.35 rc2, so new Visual Editor Parsoid PHP.


When I modify an page in the Main namespace, Visual Editor works fine.


But when creating or modifying a page in the User namespace, or when creating a page in the Main namespace, I get the following error: Error contacting the Parsoid/RESTBase server (HTTP 404).


Now reading the extension instructions it doesn't seem that I need to setup a RESTBase server, unless I want to avoid problems when switching between wikitext and Visual Editor.


Does anyone know what the problem could be?


Thank you for your help

185.69.145.64 (talkcontribs)

Been doing some further testing after reinstalling Mediawiki 1.35 rc2, and now the Main namespace works for modifying and creating pages, but the User namespace still doesn't work for either creating or modifying pages with Visual Editor.

Seb35 (talkcontribs)

I had a hard time also to configure VE on MW 1.35.0-rc.2, with the error you mentionned when trying to edit a existing page in the main namespace. It turns out that the following line must be in LocalSettings.php:

wfLoadExtension( 'Parsoid', 'vendor/wikimedia/parsoid/extension.json' );

And the domain in $wgVirtualRestConfig['modules']['parsoid']['domain'] must be the same as the one in $wgServer (but $wgVirtualRestConfig is auto-configured, so this applies only if you explicitely changed it).

148.252.133.18 (talkcontribs)

Seb35, thank you very much for the suggestion!


Unfortunately it doesn't solve the issue I am having. I did try downloading the latest git version of Parsoid and adding that version via `wfLoadExtension( 'Parsoid', "$PARSOID_INSTALL_DIR/extension.json" );` though, as explained here: Parsoid/PHP, but didn't help either.

148.252.133.18 (talkcontribs)

I did pinpoint that the error is coming from file ApiParsoidTrait.php line 160:


// error null, code not 200

$this->getLogger()->warning(

__METHOD__ . ": Received HTTP {code} from RESTBase",

[

'code' => $response['code'],

'trace' => ( new Exception )->getTraceAsString(),

'response' => $response['body'],

'requestPath' => $path,

'requestIfMatch' => $reqheaders['If-Match'] ?? '',

]

);

$this->dieWithError(

[ 'apierror-visualeditor-docserver-http', $response['code'] ],

'apierror-visualeditor-docserver-http'

);


Does anyone know how I can access those warning logs?

148.252.133.18 (talkcontribs)

Debugging the PHP directly I get:


'code':

404


'trace':

#0 /var/www/html/w/extensions/VisualEditor/includes/ApiVisualEditor.php(67): ApiVisualEditor->requestRestbase(Object(Title), 'POST', 'transform/wikit...', Array)

#1 /var/www/html/w/extensions/VisualEditor/includes/ApiVisualEditor.php(251): ApiVisualEditor->parseWikitextFragment(Object(Title), 'testtext', false, NULL, true)

#2 /var/www/html/w/includes/api/ApiMain.php(1593): ApiVisualEditor->execute()

#3 /var/www/html/w/includes/api/ApiMain.php(529): ApiMain->executeAction()

#4 /var/www/html/w/includes/api/ApiMain.php(500): ApiMain->executeActionWithErrorHandling()

#5 /var/www/html/w/api.php(90): ApiMain->execute()

#6 /var/www/html/w/api.php(45): wfApiMain()

#7 {main}


'response':

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL was not found on this server.</p> <hr> <address>Apache/2.4.38 (Debian) Server at localhost Port 80</address> </body></html>


'requestPath':

transform/wikitext/to/html/User%3AJohn%2Ftestpage

148.252.133.18 (talkcontribs)

After further testing, i can't create any subpage in the Main namespace either...

So it will only allow me to create or modify pages but no subpages at all

148.252.133.18 (talkcontribs)

ok so this is definitely a bug.


If I remove urlencode from lines 230 & 250 in file ApiParsoidTrait.php it works.


requestPath above was sanitizing : and / to %3A and %2F, and that seems to be the problem.

Seb35 (talkcontribs)

The page Parsoid/PHP is a bit old given it evolves quickly around this topic with the release of 1.35 (see phabricator:T248186 and linked tasks). In my case I used the tarball, and it seems my issue was different than yours.

Probably you can report it on Phabricator (an account will be needed), I quickly searched on Parsoid issues but I didn’t find opened tasks about encoding (well, there are some with "encod" but not really what you described).

148.252.133.18 (talkcontribs)

Thank you Seb35, I will report it on Phabricator.

148.252.133.18 (talkcontribs)
Seb35 (talkcontribs)

Thanks! I close this discussion.