Skip to content

_do_request can raise JSONDecodeError when it means to raise InternalServerError #202

@EvanKrall

Description

@EvanKrall

When Marathon returns a 502, it spits out some HTML instead of JSON:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 502 </title>
</head>
<body>
<h2>HTTP ERROR: 502</h2>
<p>Problem accessing /v2/apps. Reason:
<pre>    Failed to successfully establish a connection to the leader.</pre></p>
<hr /><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.3.z-SNAPSHOT</a><hr/>
</body>
</html>

This makes creating an InternalServerError object fail with JSONDecodeError:

Traceback (most recent call last):
...
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/paasta_tools/bounce_lib.py", line 133, in create_marathon_app
    client.create_app(app_id, MarathonApp(**config))
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/marathon/client.py", line 149, in create_app
    response = self._do_request('POST', '/v2/apps', data=data)
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/marathon/client.py", line 94, in _do_request
    raise InternalServerError(response)
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/marathon/exceptions.py", line 13, in __init__
    content = response.json()
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/requests/models.py", line 819, in json
    return json.loads(self.text, **kwargs)
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/simplejson/__init__.py", line 516, in loads
    return _default_decoder.decode(s)
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/simplejson/decoder.py", line 374, in decode
    obj, end = self.raw_decode(s)
  File "/opt/venvs/paasta-tools/local/lib/python2.7/site-packages/simplejson/decoder.py", line 404, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions