timeplus-io / proton-python-driver

Python driver for Timeplus Enterprise or Timeplus Proton
https://timeplus.com
Other
14 stars 4 forks source link

connection.py:397, write_binary_str, 'NoneType' object has no attribute 'encode' #48

Open jovezhong opened 1 month ago

jovezhong commented 1 month ago

While I am testing the dbt plugin, I hit the issue in proton_driver/connection.py:397: in send_hello

/Users/jove/Dev/py310-dbt18-env/lib/python3.10/site-packages/proton_driver/connection.py:397: in send_hello
    write_binary_str(self.database, self.fout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

text = None, buf = <proton_driver.bufferedwriter.BufferedSocketWriter object at 0x121f2dcb0>

    def write_binary_str(text, buf):
>       text = text.encode('utf-8')
E       AttributeError: 'NoneType' object has no attribute 'encode'

/Users/jove/Dev/py310-dbt18-env/lib/python3.10/site-packages/proton_driver/writer.py:15: AttributeError

I tried both Python 3.10 and 3.12, both 0.2.8 and 0.2.10. This can be reproduced with pytest --log-cli-level=DEBUG tests/functional/test_proton.py in the dbt-proton repo. But I will try to extract it and reproduce this without dbt.

jovezhong commented 1 month ago

The reason is the database can be None. In that case it fails call the encode method. Should check whether the text is none.