Page MenuHomePhabricator

VirtualRESTServiceClient returns status code 0 on Docker
Closed, ResolvedPublic

Description

After upgrading from MW REL 1.32 to REL 1.33 I encountered problems with the VirtualRESTServiceClient. In combination with Docker, it returns status code 0 instead of 200 even though the response-content is intact. I can not reproduce the problem locally. Unfortunately, I have no idea how to further debug this problem. Any help is appreciated...

PS: I am using a slightly modified version of the official MediaWiki Docker images. However, since the official MediaWiki Docker images do not contain VE or Math. I can not test with them. https://github.com/physikerwelt/mediawiki-docker

Event Timeline

hashar subscribed.

https://doc.wikimedia.org/docker-pkg/ is a software to define a fleat of Dockerfile using a templating engine, so unrelated.

Can this be related to T202352, since we use MultiHttpClient https://github.com/wikimedia/mediawiki-extensions-Math/blob/54d1b77401a250d24a6923193c5c73459a10c2c2/src/MathRestbaseInterface.php#L170 ? I wonder if I am the only one seeing status code 0?

This is unlikely the case because the ticket hasn't been implemented yet. Have you tried printing the complete HTTP response you get? How often does it happen? Are there special circumstances in which this occurs?

Change 552527 had a related patch set uploaded (by Physikerwelt; owner: Physikerwelt):
[mediawiki/core@master] WIP: MWHttpRequest regression demo

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

I did some debugging and it seems this is neither related to containers nor related to restbase. I came up with a minimal post request example. While this example uses restbase I also tried accessing mathoid directly from localhost. One idea is, that this might potentially be related to T202352.

Change 552528 had a related patch set uploaded (by Physikerwelt; owner: Physikerwelt):
[mediawiki/core@REL1_32] WIP: MWHttpRequest regression demo

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

Jenkins confirmed my local experiments. I will try to dig a bit deeper and see if I can trace down the problem.

Got it. MW1_32 used php_curl and in particular this line

$this->curlOptions[CURLOPT_POST] = true;

tells libcurl to do a regular HTTP post. This will also make the library use a "Content-Type: application/x-www-form-urlencoded" header. (This is by far the most commonly used POST method). cf. https://curl.haxx.se/libcurl/c/CURLOPT_POST.html

In the new implementation this is missing.
I'll upload the fix soon.

Change 552528 abandoned by Physikerwelt:
WIP: MWHttpRequest regression demo

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

Writing the test was actually harder than the fix. However, I could also understand if one considers adding a test middelware to evaluate the request header is overdone. However, the Middleware exists in the library anyhow and I can not imagine another conceptually solid approach.

WDoranWMF added subscribers: BPirkle, WDoranWMF.

hey @Physikerwelt I'm unassigning @BPirkle as he's working on one of our product teams right now, but I've moved this into our CR pipeline.

@WDoranWMF thank you. The CR for the main part is trivial. However, for the testing framework, it would be great to get someone with experience in the Guzzle framework involved.

This is either a UBN or a high priority as VisualEditor is broken on debian buster+ based on testing.

MediaWiki version: 1.33 and php version 7.3.

From what i can tell https://github.com/wikimedia/mediawiki-extensions-VisualEditor/commit/9ce8ae05c727694e54c961f3e2dd6a2b60892848#diff-b781650abf89f11630b68fce3d572daeR117 is returning the 'code' = 0.

And from the log when i cherry picked the change + your other one:

2019-11-30 22:35:55 mw2.miraheze.org metawiki: ApiVisualEditor::requestRestbase: Received HTTP 0 from RESTBase for page/html/Miraheze/89991?redirect=false. Trace: #0 /srv/mediawiki/w/extensions/VisualEditor/includes/ApiVisualEditor.php(289): ApiVisualEditor->requestRestbase(Object(Title), 'GET', 'page/html/Mirah...', Array)
#1 /srv/mediawiki/w/includes/api/ApiMain.php(1593): ApiVisualEditor->execute()
#2 /srv/mediawiki/w/includes/api/ApiMain.php(531): ApiMain->executeAction()
#3 /srv/mediawiki/w/includes/api/ApiMain.php(502): ApiMain->executeActionWithErrorHandling()
#4 /srv/mediawiki/w/api.php(87): ApiMain->execute()
#5 {main} Response: <!DOCTYPE html>.......(ton more content)

When i curl curl -I https://parsoid-lb.miraheze.org/meta.miraheze.org/v4/page/html/Miraheze/89991?redirect=false i get a good response not a 0. But this only happens on debian buster not debian stretch. So i'm thinking the curl version used has different behaviour?

(Confirmed broken on 2 debian buster instances where as works under 3 stretch instances)

Change 553859 had a related patch set uploaded (by Paladox; owner: Paladox):
[mediawiki/core@master] Fix support for HTTP/2 in MultiHttpClient

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

Change 553862 had a related patch set uploaded (by Reedy; owner: Paladox):
[mediawiki/core@REL1_34] Fix support for HTTP/2 in MultiHttpClient

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

Change 553863 had a related patch set uploaded (by Reedy; owner: Paladox):
[mediawiki/core@REL1_33] Fix support for HTTP/2 in MultiHttpClient

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

Change 553864 had a related patch set uploaded (by Reedy; owner: Paladox):
[mediawiki/core@REL1_32] Fix support for HTTP/2 in MultiHttpClient

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

Change 553865 had a related patch set uploaded (by Reedy; owner: Paladox):
[mediawiki/core@REL1_31] Fix support for HTTP/2 in MultiHttpClient

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

Change 553859 merged by jenkins-bot:
[mediawiki/core@master] Fix support for HTTP/2 in MultiHttpClient

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

Change 553865 merged by jenkins-bot:
[mediawiki/core@REL1_31] Fix support for HTTP/2 in MultiHttpClient

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

Change 553864 merged by jenkins-bot:
[mediawiki/core@REL1_32] Fix support for HTTP/2 in MultiHttpClient

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

Change 553863 merged by jenkins-bot:
[mediawiki/core@REL1_33] Fix support for HTTP/2 in MultiHttpClient

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

Change 553862 merged by jenkins-bot:
[mediawiki/core@REL1_34] Fix support for HTTP/2 in MultiHttpClient

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

Change 552527 merged by jenkins-bot:
[mediawiki/core@master] Mimic CURLOPT_POST in GuzzleHttpRequest

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

Change 554554 had a related patch set uploaded (by Paladox; owner: Physikerwelt):
[mediawiki/core@REL1_34] Mimic CURLOPT_POST in GuzzleHttpRequest

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

Change 554555 had a related patch set uploaded (by Paladox; owner: Physikerwelt):
[mediawiki/core@REL1_33] Mimic CURLOPT_POST in GuzzleHttpRequest

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

Change 554554 merged by jenkins-bot:
[mediawiki/core@REL1_34] Mimic CURLOPT_POST in GuzzleHttpRequest

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

Change 554555 merged by jenkins-bot:
[mediawiki/core@REL1_33] Mimic CURLOPT_POST in GuzzleHttpRequest

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

Seems resolved now.