-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Surface HTML errors #121
Surface HTML errors #121
Conversation
@gianm seems like that should be fixed upstream, but PyDruid should probably handle it as well for the sake of supporting previous versions. |
@betodealmeida the build failed :( |
Looks like |
pydruid/client.py
Outdated
|
||
from six.moves import urllib | ||
|
||
from pydruid.query import QueryBuilder | ||
from base64 import b64encode | ||
|
||
try: | ||
# available only in Python >= 3.5 | ||
from json.decoder import JSONDecodeError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like JSONDecodeError
is derived from ValueError
, so catching ValueError
should just work and remove the need for this extra complexity.
tests/test_client.py
Outdated
@patch('pydruid.client.urllib.request.urlopen') | ||
def test_druid_returns_html_error(self, mock_urlopen): | ||
# given | ||
message = """<html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: there's this trick indent long strings in code but not in the variable itself:
s = textwrap.dedent"""\
this
wont
be indented
"""
Our Druid cluster is returning an HTML error message when OOMing:
This message is not surfaced correctly to the client, since the client expects a JSON response from Druid. Here's how it's currently surfaced:
I modified the code that checks for errors in the client so that if an HTML response is returned the error message is correctly extracted from the
<PRE></PRE>
tags. With this, the error is surfaced correctly (although somewhat verbose):