Page MenuHomePhabricator

Error contacting the Parsoid/RESTBase server (HTTP 400)
Open, Needs TriagePublic

Description

Hi everyone.
I'm using nginx as a proxy (for tls termination) for my mediawiki 1.35 installation, which itself runs on apache. I have trouble making the Visual Editor working, right now I cannot use it to interact with the wiki. The non-visual editor works as expected. Please note this might be related to https://phabricator.wikimedia.org/T249997 .

From the Visual Editor UX, the error message I get is the following, whenever I click on "edit this page":

Error contacting the Parsoid/RESTBase server (HTTP 400)

Checking what happens, it seems that Mediawiki is making a GET request to itself on the /rest.php/wiki.sciences.re/v3/page/html/Main_Page/1?redirect=false&stash=true path, request which fails because the promise-non-write-api-action: true header is present, which results in a 400 http code with the following message:

The 'Promise-Non-Write-API-Action' HTTP header was sent but the request was to an API write module.

This might be related to https://github.com/wikimedia/mediawiki/blob/master/includes/api/ApiMain.php#L1467 or https://github.com/wikimedia/mediawiki/blob/master/includes/WebStart.php#L94.

Such a message is "hidden", and I only saw it using tcpdump to check the requests between the nginx frontend and the apache "backend".

I'm wondering if this is a mistake in my configuration, or a bug elsewhere.

Here are the detailed "tcpdump" logs:

08:27:45.252115 IP localhost.40468 > localhost.cbt: Flags [P.], seq 2218589125:2218589775, ack 3078592587, win 512, options [nop,nop,TS val 1757161229 ecr 1757161229], length 650
E..."S@.@..............a.<.....K...........
h.'.h.'.GET /api.php?action=visualeditor&format=json&paction=parse&page=Main_Page&uselang=en&formatversion=2 HTTP/1.0
Host: wiki.sciences.re
X-Real-IP: 91.86.53.70
X-Forwarded-For: 91.86.53.70
X-Forwarded-Proto: https
X-Forwarded-Host: wiki.sciences.re
X-Forwarded-Server: wiki.sciences.re
Connection: close
user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0
accept: application/json, text/javascript, */*; q=0.01
accept-language: en-US,en;q=0.5
x-requested-with: XMLHttpRequest
referer: https://wiki.sciences.re/index.php?title=Main_Page&veaction=edit
cookie: mediawikiUserName=Remy.grunblatt; VEE=visualeditor


08:27:45.581493 IP localhost.40472 > localhost.cbt: Flags [P.], seq 4276759063:4276759633, ack 3399028897, win 512, options [nop,nop,TS val 1757161558 ecr 1757161558], length 570
E..n..@.@.y............a..*..........c.....
h.(Vh.(VGET /rest.php/wiki.sciences.re/v3/page/html/Main_Page/1?redirect=false&stash=true HTTP/1.0
Host: wiki.sciences.re
X-Real-IP: 2001:bc8:47b0:2640::1
X-Forwarded-For: 2001:bc8:47b0:2640::1
X-Forwarded-Proto: https
X-Forwarded-Host: wiki.sciences.re
X-Forwarded-Server: wiki.sciences.re
Connection: close
Content-Length: 0
accept: text/html; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/HTML/2.0.0"
accept-language: en
user-agent: VisualEditor-MediaWiki/1.35.1
api-user-agent: VisualEditor-MediaWiki/1.35.1
promise-non-write-api-action: true


08:27:45.871029 IP localhost.cbt > localhost.40472: Flags [P.], seq 1:494, ack 570, win 512, options [nop,nop,TS val 1757161848 ecr 1757161558], length 493
E..!..@.@.L8.........a........,Q...........
h.)xh.(VHTTP/1.1 400 Bad Request
Date: Thu, 01 Apr 2021 08:27:45 GMT
Server: Apache/2.4.46 (Unix)
X-Powered-By: PHP/7.3.23
X-Content-Type-Options: nosniff
Cache-Control: no-cache
X-Request-Id: b3bb3d7d393cfe9f73570149
Content-Length: 194
Connection: close
Content-Type: text/html; charset=utf-8

<!DOCTYPE html>
<html>
<head><meta charset="UTF-8" /></head>
<body>
The &#039;Promise-Non-Write-API-Action&#039; HTTP header was sent but the request was to an API write module.
</body>
</html>

08:27:45.946722 IP localhost.cbt > localhost.40468: Flags [P.], seq 1:811, ack 650, win 512, options [nop,nop,TS val 1757161924 ecr 1757161229], length 810
E..^d!@.@..v.........a.....K.<.O.....S.....
h.).h.'.HTTP/1.1 200 OK
Date: Thu, 01 Apr 2021 08:27:45 GMT
Server: Apache/2.4.46 (Unix)
X-Powered-By: PHP/7.3.23
X-Content-Type-Options: nosniff
MediaWiki-API-Error: apierror-visualeditor-docserver-http
X-Frame-Options: DENY
Content-Disposition: inline; filename=api-result.json
Cache-Control: private, must-revalidate, max-age=0
X-Request-Id: 6d607b6d8417b862f3356726
Connection: close
Content-Type: application/json; charset=utf-8

{"error":{"code":"apierror-visualeditor-docserver-http","info":"Error contacting the Parsoid/RESTBase server (HTTP 400)","docref":"See https://wiki.sciences.re/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes."}}

Event Timeline

It seems that you have incompatible versions of VisualEditor and MediaWiki – this error would occur if your VisualEditor included this patch: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/661936, but your MediaWiki did not include this patch: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/661934.

Can you try re-installing both from the same source? (either the tarball, or the Git branches)

Hello,

This was indeed the problem ! I feel my mistake might be a very classical mistake: I went straight for the download link (my bad), which brought me to https://www.mediawiki.org/wiki/Special:ExtensionDistributor/VisualEditor and I saw "1.35 (latest stable mediawiki)" and thought that was ok since I was also using 1.35.1.

I'm glad you got it working. I think we can close this task now.

(And thanks for the details in the report, this should help anyone who runs into the same problem in the future.)

We should make VisualEditor REL1_35 require MediaWiki 1.35.2 now that it's been released, I'll submit a patch.

Change 680134 had a related patch set uploaded (by Legoktm; author: Legoktm):

[mediawiki/extensions/VisualEditor@REL1_35] Require MediaWiki >= 1.35.2

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

Change 680134 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@REL1_35] Require MediaWiki >= 1.35.2

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

I reopen the issue because I'm facing exactly the same behavior with MediaWiki 1.35.2 (installed from tar.gz, not git), also behind nginx proxy. I can also read from tcpdump:

The &#039;Promise-Non-Write-API-Action&#039; HTTP header was sent but the request was to an API write module.

How can I help (my knowledge with programming is limited though)?

Hi just wanted to say thanks for this issue/thread and solution! I did all the debugging you did as well (finding Promise-Non-Write-API-Action) and I'd never have guessed that it was a version mismatch between VE and MW, no idea how that happened, but fully upgrading to MW 1.35.2 fixed it! Cheers!

@CharlesNepote just saying it works for me with that version on nginx. Are you sure you're using the VE version shipped with MW?