Page MenuHomePhabricator

Error response structure is not as documented
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

A request to /v2/translate/{from}/{to}/{provider} that results in an error returns a non-JSON string, but the documentation says that it should return JSON conforming to the problem schema. It'd be more useful if it returned the latter.

For example, a valid request looks like this:

$ curl 'https://cxserver.wikimedia.org/v2/translate/es/en/MinT' -i -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw $'{"html":"<span>Hola Mundo</span>"}'
HTTP/2 200 
content-type: application/json; charset=utf-8
content-length: 15

{"contents":""}

(I've removed irrelevant headers from the response, and the fact that there's no translation doesn't seem to matter; this issue is the same with /v2/translate/ and /v1/mt/, and the latter does return a translation.)

A request to translate to German instead (which is not a supported language), results in a 404, non-JSON, response with just the text "Provider not supported", e.g.:

$ curl 'https://cxserver.wikimedia.org/v2/translate/en/de/MinT' -i -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data-raw $'{"html":"<span>Hola Mundo</span>"}'
HTTP/2 404 
content-length: 22

Provider not supported

This should instead be returning something like:

{
  "status": 404,
  "type": "…",
  "title": "Provider not supported",
  "detail": "The target language 'de' is not supported.",
  "method": "POST",
  "uri": "…"
}

Event Timeline

PWaigi-WMF moved this task from Backlog to Other teams on the CX-cxserver board.

I think the "Provider not supported" message is also wrong, because the issue is that the to language de is not supported, not the provider MinT. Should I raise that as a separate task?

Change #1289175 had a related patch set uploaded (by Santhosh; author: Santhosh):

[mediawiki/services/cxserver@master] Return JSON error responses from MT translate endpoints

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

Change #1289175 merged by jenkins-bot:

[mediawiki/services/cxserver@master] Return JSON error responses from MT translate endpoints

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

Change #1292915 had a related patch set uploaded (by KartikMistry; author: KartikMistry):

[operations/deployment-charts@master] Update cxserver to 2026-05-24-103047-production

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

Change #1292915 merged by jenkins-bot:

[operations/deployment-charts@master] Update cxserver to 2026-05-24-103047-production

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

Mentioned in SAL (#wikimedia-operations) [2026-05-25T12:58:52Z] <kart_> Updated cxserver to 2026-05-24-103047-production (T426808, T373418)

Nikerabbit set the point value for this task to 2.Mon, Jun 1, 7:17 AM