Skip to content
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

Error when the error response is in bytes format #192

Open
EmadMokhtar opened this issue Feb 12, 2020 · 1 comment · May be fixed by #193
Open

Error when the error response is in bytes format #192

EmadMokhtar opened this issue Feb 12, 2020 · 1 comment · May be fixed by #193

Comments

@EmadMokhtar
Copy link

EmadMokhtar commented Feb 12, 2020

Overview

We are getting errors from the Druid APIs but it is in a bytes format b''. When the error response passed to the json.loads() it will crash. I think this happening after this PR #121.

Error Details

        except urllib.error.HTTPError as e:
            err = e.read()
            if e.code == 500:
                # has Druid returned an error?
                try:
                    err = json.loads(err)  # ERROR HAPPEN HERE
                except ValueError:
                    if HTML_ERROR.search(err):
                        err = HTML_ERROR.search(err).group(1)
                except (ValueError, AttributeError, KeyError):
                    pass
err = b'{"error":"Unknown exception","errorMessage":"Failure getting results for query[85d259df-c0ea-43c7-93d9-49e609b3b203] url[http://druid/druid/v2/] because of [org.jboss.netty.channel.ChannelException: Channel disconnected]","errorClass":"org.apache.druid.java.util.common.RE","host":null}'

versions

  • Druid version: 0.16.0
  • Python: 3.5.3
  • PyDruid: 0.5.7
@EmadMokhtar
Copy link
Author

I will try to fix this.

Plan

I have a simple plan to fix this issue. I will check if the content of the error message (HTTP response) is in a byte format, then I will decode it.

@EmadMokhtar EmadMokhtar linked a pull request Feb 13, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant