10000 dump_devinfo crashes when credentials are not given · Issue #591 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content
dump_devinfo crashes when credentials are not given #591
Closed
@rytilahti

Description

@rytilahti

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0