Skip to content

dump_devinfo crashes when credentials are not given #591

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

Closed
rytilahti opened this issue Dec 28, 2023 · 1 comment · Fixed by #593
Closed

dump_devinfo crashes when credentials are not given #591

rytilahti opened this issue Dec 28, 2023 · 1 comment · Fixed by #593
Labels
bug Something isn't working

Comments

@rytilahti
Copy link
Member

The dump_devinfo script defaults to None which causes a crash inside the transport for non-legacy devices:

Testing Call(module='component_nego', method='component_nego')..FAIL Unable to connect to the device: 192.168.x.x: 'NoneType' object has no attribute 'encode'
Traceback (most recent call last):
  File "/home/tpr/code/python-kasa/kasa/smartprotocol.py", line 89, in _query
    return await self._execute_query(request, retry)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tpr/code/python-kasa/kasa/smartprotocol.py", line 160, in _execute_query
    response_data = await self._transport.send(smart_request)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tpr/code/python-kasa/kasa/aestransport.py", line 265, in send
    await self.perform_login()
  File "/home/tpr/code/python-kasa/kasa/aestransport.py", line 192, in perform_login
    await self._perform_login_for_version(login_version=2)
  File "/home/tpr/code/python-kasa/kasa/aestransport.py", line 175, in _perform_login_for_version
    un, pw = self.hash_credentials(login_version == 2)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tpr/code/python-kasa/kasa/aestransport.py", line 91, in hash_credentials
    _sha1(self._credentials.username.encode()).encode()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'encode'

This is likely a regression, but passing "" as default in the script will cause another failure that could be handled more gracefully.
Ping @sdb9696 just in case you are not subscribed to new issues & PRs in the repository :-)

Also, the help text in https://github.com/python-kasa/python-kasa/tree/master/devtools#dump_devinfo should be updated.

@rytilahti rytilahti added the bug Something isn't working label Dec 28, 2023
@sdb9696
Copy link
Collaborator

sdb9696 commented Dec 29, 2023

I have a draft PR to fix this here which I'll rebase on top of #569 once it's merged. I've also now subscribed to all PR & Issue activity notifications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants