Page MenuHomePhabricator

MW API requests to (without the www subdomain) fail
Closed, ResolvedPublic


Our calls to the MediaWiki API via api-util.js/mwApiGet are returning the auto-generated error HTML page when a domain of '' is used. If '' is used, the request is successful.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 408863 had a related patch set uploaded (by Mholloway; owner: Mholloway):
[mediawiki/services/mobileapps@master] Throw an error if the MediaWiki API responds with text/html

Change 408863 merged by jenkins-bot:
[mediawiki/services/mobileapps@master] Throw an error if the MediaWiki API responds with text/html

I've merged this since it's definitely an improvement over

"status": 400,
"type": "internal_error",
"detail": "400",
"method": "GET",
"uri": "/"

When I run the same MW API request our api calls make with curl I get a 301:

$ curl -X POST -d "action=query&lllimit=max&pilicense=any&piprop=thumbnail%7Coriginal%7Cname&pithumbsize=1024&wbptterms=description&inprop=protection&rvprop=ids%7Ctimestamp%7Cuser%7Ccontentmodel&titles=How_to_contribute&prop=coordinates%7Cpageprops%7Cpageimages%7Cpageterms%7Crevisions%7Cinfo%7Clanglinks&format=json&formatversion=2&continue=" ""

<title>301 Moved Permanently</title>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="">here</a>.</p>

Our output (with your patch applied) shows the API help page instead. Any idea why that is?

I was just about to note the same thing. cURL returns a 301 when POSTing to, but the Postman app (and, evidently, our internal service requests) return 200 and the help page HTML. I'm not sure why this discrepancy exists.

Mentioned in SAL (#wikimedia-operations) [2018-02-07T21:44:26Z] <bsitzmann@tin> Started deploy [mobileapps/deploy@fe3cd60]: Update mobileapps to 7a3b19c (T186745 T186643)

Mentioned in SAL (#wikimedia-operations) [2018-02-07T21:51:07Z] <bsitzmann@tin> Finished deploy [mobileapps/deploy@fe3cd60]: Update mobileapps to 7a3b19c (T186745 T186643) (duration: 06m 41s)

Some comments between @Mholloway and myself on IRC -services channel earlier with minor edits:

As far as POSTing to, i guess in this case we could just special-case and rewrite to seems like kind of a one-off issue.

Since this is a redirect issue I think RB should handle that, just for consistency sake.

This probably shouldn't happen: I guess it does moot the issue for us, though, at least as far as prod is concerned; those requests will never reach MCS

bearND claimed this task.

For posterity and completeness, you are witnessing the difference because Varnish does the redirect in this case. This is why you get the help page in a browser (which automatically follow redirects), a 301 with curl and an error with api-util (because that request hits the MW API servers directly, which do not have the notion of domain redirects).