When using the X-Wikimedia-Debug header or the WikimediaDebug extension, requests to api.wikimedia.org seem to get routed directly to mw-debug API servers without going through the REST Gateway.
This has the unfortunate side-effect of breaking change testing with X-W-D that rely on client-side calls to api.wikimedia.org.
# XWD with Origin hits mw-debug directly and gets a mediawiki 404 ❯ curl -s -I -H 'X-Wikimedia-Debug: backend=k8s-mwdebug' -H 'Origin: meta.wikimedia.org' https://api.wikimedia.org/service/lw/specs/openapi.yaml | grep -e 'HTTP\|server:' HTTP/2 404 server: mw-debug.eqiad.pinkunicorn-6b7fbd968c-2n2vm # XWD without Origin hits mw-debug directly and gets a mediawiki 404 ❯ curl -s -I -H 'X-Wikimedia-Debug: backend=k8s-mwdebug' https://api.wikimedia.org/service/lw/specs/openapi.yaml | grep -e 'HTTP\|server:' HTTP/2 404 server: mw-debug.eqiad.pinkunicorn-6b7fbd968c-2n2vm # No XWD hits the Apache backend service through the rest-gateway ❯ curl -s -I https://api.wikimedia.org/service/lw/specs/openapi.yaml | grep -e 'HTTP\|server:' HTTP/2 200 server: Apache/2.4.67 (Debian) # Same with an Origin ❯ curl -s -I -H 'Origin: meta.wikimedia.org' https://api.wikimedia.org/service/lw/specs/openapi.yaml | grep -e 'HTTP\|server:' HTTP/2 200 server: Apache/2.4.67 (Debian)
From T430600: WikimediaDebug makes api.wikimedia.org always 301 redirect:
Steps to replicate the issue (include links if applicable):
Make sure the WikimediaDebug extension is installed, but not turned on Visit https://api.wikimedia.org/service/linkrecommendation/v1/linkrecommendations/wikipedia/en/Apple Turn on WikimediaDebug Visit https://api.wikimedia.org/service/linkrecommendation/v1/linkrecommendations/wikipedia/en/Apple againWhat happens?:
The first load should show some JSON.
The second load will 301 redirect to https://www.mediawiki.org/wiki/Wikimedia_APIs
Further loads of that URL will have the 301 cached for about an hour.
What should have happened instead?:
No redirect should happen.
Investigate, and maybe find a way to have XWD API requests hit the rest-gateway and *then* be routed to mw-debug backends when appropriate, or normal production backends for non MediaWiki APIs.
As a quick fix, either:
- Add an exception to modules/profile/files/trafficserver/x-wikimedia-debug-routing.lua that does not remap the host:port when the original host is api.wikimedia.org.
or
- Remove x-wikimedia-debug-routing.lua from the ATS plugin chain for api.wikimedia.org