Page MenuHomePhabricator

REST API returns JSON but complains about unsupported target format when Accept header requests the same
Open, MediumPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

First, make a simple REST API request without an explicit Accept header (curl will send Accept: */* by default):

curl -A T412610 -i -d wikitext=test https://en.wikipedia.org/w/rest.php/v1/transform/wikitext/to/lint

Then, make the same request with an Accept: application/json header (which adds the same Accept header, along with a different Content-Type for the request body):

curl -A T412610 -i -d wikitext=test -H 'Accept: application/json' https://en.wikipedia.org/w/rest.php/v1/transform/wikitext/to/lint

You can also get the same result with curl’s --json option:

curl -A T412610 -i --json='{"wikitext": "test"}' https://en.wikipedia.org/w/rest.php/v1/transform/wikitext/to/lint

What happens?:
While the first request correctly returns JSON –

HTTP/2 200 
content-type: application/json
snip: many other headers

[]

– the second request returns an error:

HTTP/2 406 
content-type: application/json
snip: many other headers

{"errorKey":"rest-unsupported-target-format","messageTranslations":{"en":"The requested target format is not supported."},"httpCode":406,"httpReason":"Not Acceptable"}

What should have happened instead?:
Both requests should return the same response, given that Accept: application/json asks for the same Content-Type that the API returns by default anyways.

Other information (browser name/version, screenshots, etc.):
I have not yet tested if other REST API endpoints are affected.

Event Timeline

I have not yet tested if other REST API endpoints are affected.

Upon closer inspection, TransformHandler is the only class that can emit this errorKey (and technically RevisionSourceHandler but only if it’s been wired up incorrectly), so I’m guessing only the various transform endpoints handled by this class are affected. (The acceptable() method which is used to decide whether to raise the error is defined in the parent class ParsoidHandler, but never called there, only in the TransformHandler subclass.)

Other endpoints apparently just ignore the Accept request header, which is not really better…

$ curl -H 'Accept: application/json' https://en.wikipedia.org/w/rest.php/v1/page/Main_Page/bare
{"id":15580374,"key":"Main_Page","title":"Main Page","latest":{"id":1325821473,"timestamp":"2025-12-05T10:53:59Z"},"content_model":"wikitext","license":{"url":"https://creativecommons.org/licenses/by-sa/4.0/deed.en","title":"Creative Commons Attribution-Share Alike 4.0"},"html_url":"https://en.wikipedia.org/w/rest.php/v1/page/Main%20Page/html"}
$ curl -H 'Accept: text/plain' https://en.wikipedia.org/w/rest.php/v1/page/Main_Page/bare
{"id":15580374,"key":"Main_Page","title":"Main Page","latest":{"id":1325821473,"timestamp":"2025-12-05T10:53:59Z"},"content_model":"wikitext","license":{"url":"https://creativecommons.org/licenses/by-sa/4.0/deed.en","title":"Creative Commons Attribution-Share Alike 4.0"},"html_url":"https://en.wikipedia.org/w/rest.php/v1/page/Main%20Page/html"}
$ curl -H 'Accept: application/vnd.microsoft.portable-executable' https://en.wikipedia.org/w/rest.php/v1/page/Main_Page/bare
{"id":15580374,"key":"Main_Page","title":"Main Page","latest":{"id":1325821473,"timestamp":"2025-12-05T10:53:59Z"},"content_model":"wikitext","license":{"url":"https://creativecommons.org/licenses/by-sa/4.0/deed.en","title":"Creative Commons Attribution-Share Alike 4.0"},"html_url":"https://en.wikipedia.org/w/rest.php/v1/page/Main%20Page/html"}
aaron triaged this task as Medium priority.Dec 17 2025, 7:33 AM
aaron moved this task from Incoming (Needs Triage) to Next Up on the MW-Interfaces-Team board.