esi/esi-issues

Endpoint returns plain text response for 400 bad request, but swagger client expects JSON

Opened this issue · 0 comments

Bug

When requesting names from the asset names endpoint I am sometimes receiving an HTML text response for a 400 status instead of JSON. This confuses my swagger client, which is expecting a JSON response according to specs. This issue prevents the swagger client to map the response to a proper error type and leads to generic errors (e.g. "undefined response type") , which make it very hard to debug.

This is happening with the goesi client, which is used a generated swagger client. This appears to be a known weakness of the swagger client 1. However, I would regard this still as a bug, since the endpoint violates its the specs

This issue very likely also effects other swagger clients. For example I have seen django-esi sometimes producing a generic OSError 2, instead of one of the expected ESI error exceptions for endpoints.

Side note: I am suspecting the 400 response here is not correct here, since the same request goes through fine just a few attempts later. But this is not what this issue is about.

Request

POST url=https://esi.evetech.net/v1/characters/93507995/assets/names/ 
method=POST url=https://esi.evetech.net/v1/characters/93507995/assets/names/ header="map[Accept:[application/json] Authorization:[Bearer TOKEN] Content-Type:[application/json]]"  body="[1039639899207,1039639899210]\n"

The request is shortened for brevity. The actual request contains 1000 IDs.

Response

Status Code

400

Headers

Content-Length: "122"
Content-Type: "text/html"

Body

<html>\r\n<head><title>400 Bad Request</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n</body>\r\n</html>\r\n

Expected

{
  "error": "Bad request"
}

Checklist

Check all boxes that apply to this issue:

  • Bug description is provided
  • Request path is provided
  • Response status code is provided
  • Response headers are provided
  • Response body is provided
  • Expected response is provided

Footnotes

  1. See also https://github.com/swagger-api/swagger-codegen/issues/10997

  2. See also https://gitlab.com/allianceauth/django-esi/-/issues/15