Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

In avatica/client.py, response_body is of type bytes, but JettyErrorPageParser().feed(html) expects type string. #12

Open
deragon opened this issue Apr 11, 2019 · 1 comment

Comments

@deragon
Copy link

deragon commented Apr 11, 2019

In avatica/client.py, line 509, we find:

response_body = response.read()

if response.status != httplib.OK:
    logger.debug("Received response\n%s", response_body)
    if b'<html>' in response_body:
        parse_error_page(response_body)
    else:
        # assume the response is in protobuf format
        parse_error_protobuf(response_body)
    raise errors.InterfaceError('RPC request returned invalid status code', response.status)

The problem is that the response_body is of type bytes while for the
function parse_error_page()'s call to parser.feed(html) expects a
string (parser being instantiated from a call to JettyErrorPageParser()).

Below a full stacktrace showing the problem. Locally, I modified the file
avatica.py (not sure why my dependency downloaded from pip is not
client.py, but the files are similar and the bug are in both files) and changed:

response_body = response.read().decode('utf-8')

...and it worked; I finally got the error message showing up. Not sure that
this simple fix would work with all uses of response_body. Further code
review and testing would be required. Also, here we make the assumption
(probably good) that the Phoenix server always return UTF-8 documents, but that
must be validated.

Traceback (most recent call last):
  File "./pythonscript", line 224, in mainwrapper
    main()
  File "./pythonscript", line 210, in main
    phoenix_cursor = phoenix_connect().cursor()
  File "./pythonscript", line 51, in phoenix_connect
    return phoenixdb.connect(phoenix_url, autocommit=True)
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/__init__.py", line 67, in connect
    return Connection(client, **kwargs)
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/connection.py", line 56, in __init__
    self.open()
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/connection.py", line 73, in open
    self._client.open_connection(self._id, info=self._connection_args)
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/avatica.py", line 329, in open_connection
    response_data = self._apply(request)
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/avatica.py", line 212, in _apply
    if b'<html>' in response_body:
TypeError: 'in <string>' requires string as left operand, not bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./pythonscript", line 229, in <module>
    mainwrapper()
  File "./pythonscript", line 227, in mainwrapper
    logger.error("Exception lancée:  %s", exception.message)
AttributeError: 'TypeError' object has no attribute 'message'
Exception ignored in: <bound method Connection.__del__ of <phoenixdb.connection.Connection object at 0x7fa90be2ce80>>
Traceback (most recent call last):
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/connection.py", line 61, in __del__
    self.close()
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/connection.py", line 89, in close
    self._client.close_connection(self._id)
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/avatica.py", line 341, in close_connection
    self._apply(request)
  File "/home/myuser/.local/lib/python3.6/site-packages/phoenixdb/avatica.py", line 212, in _apply
    if b'<html>' in response_body:
TypeError: 'in <string>' requires string as left operand, not bytes
@lalinsky
Copy link
Owner

The python library is now maintenanced in the phoenix repo. They took over ownership of the project. Could you please open the issue on the phoenix mailing list?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants