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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle additional bluetooth start exceptions #76096

Merged
merged 6 commits into from Aug 2, 2022

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Aug 2, 2022

Proposed change

Improves the error reporting so the user has a better chance
of fixing out what is wrong

There are a few upstream PRs that will help as well but they likely won't be out the door in time for release
hbldh/bleak#919
hbldh/bleak#918
hbldh/bleak#920

The following exceptions are now handled

2022-08-02 09:23:42.854 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 324, in async_init
    reply = await self._bus.call(
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 305, in call
    await future
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 365, in _message_reader
    if self._unmarshaller.unmarshall():
  File "/usr/local/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 289, in unmarshall
    self._unmarshall()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 242, in _unmarshall
    raise InvalidMessageError("Expecting endianness as the first byte")
dbus_next.errors.InvalidMessageError: Expecting endianness as the first byte
2022-08-02 09:29:00.722 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 290, in async_init
    await self._bus.connect()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 149, in connect
    await self._authenticate()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 380, in _authenticate
    await self._loop.sock_sendall(self._sock, b0)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 441, in sock_sendall
    n = sock.send(data)
BrokenPipeError: [Errno 32] Broken pipe

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 馃 Silver
  • 馃 Gold
  • 馃弳 Platinum

To help with the load of incoming pull requests:

Improves the error reporting so the user has a better chance
of fixing out what is wrong

The following exceptions are now handled
```
2022-08-02 09:23:42.854 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 324, in async_init
    reply = await self._bus.call(
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 305, in call
    await future
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 365, in _message_reader
    if self._unmarshaller.unmarshall():
  File "/usr/local/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 289, in unmarshall
    self._unmarshall()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 242, in _unmarshall
    raise InvalidMessageError("Expecting endianness as the first byte")
dbus_next.errors.InvalidMessageError: Expecting endianness as the first byte
```
```
2022-08-02 09:29:00.722 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 290, in async_init
    await self._bus.connect()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 149, in connect
    await self._authenticate()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 380, in _authenticate
    await self._loop.sock_sendall(self._sock, b0)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 441, in sock_sendall
    n = sock.send(data)
BrokenPipeError: [Errno 32] Broken pipe
```
Improves the error reporting so the user has a better chance
of fixing out what is wrong

The following exceptions are now handled
```
2022-08-02 09:23:42.854 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 324, in async_init
    reply = await self._bus.call(
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 305, in call
    await future
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 365, in _message_reader
    if self._unmarshaller.unmarshall():
  File "/usr/local/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 289, in unmarshall
    self._unmarshall()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/_private/unmarshaller.py", line 242, in _unmarshall
    raise InvalidMessageError("Expecting endianness as the first byte")
dbus_next.errors.InvalidMessageError: Expecting endianness as the first byte
```
```
2022-08-02 09:29:00.722 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 290, in async_init
    await self._bus.connect()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 149, in connect
    await self._authenticate()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 380, in _authenticate
    await self._loop.sock_sendall(self._sock, b0)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 441, in sock_sendall
    n = sock.send(data)
BrokenPipeError: [Errno 32] Broken pipe
```
@bdraco bdraco added this to the 2022.8.0 milestone Aug 2, 2022
@probot-home-assistant probot-home-assistant bot added integration: bluetooth small-pr PRs with less than 30 lines. labels Aug 2, 2022
@project-bot project-bot bot added this to Needs review in Dev Aug 2, 2022
@project-bot project-bot bot moved this from Needs review to By Code Owner in Dev Aug 2, 2022
@bdraco bdraco marked this pull request as ready for review August 2, 2022 21:24
Dev automation moved this from By Code Owner to Reviewer approved Aug 2, 2022
Copy link
Member

@Jc2k Jc2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, these errors look really helpful 馃憤

@frenck
Copy link
Member

frenck commented Aug 2, 2022

Shouldn't some of these raise repairable issues instead?

@bdraco
Copy link
Member Author

bdraco commented Aug 2, 2022

Shouldn't some of these raise repairable issues instead?

I think that would be a nice improvement for the next PR. I wanted to address the most common issues for release rollout and since I've got a whole lot of reports to triage I won't be able to get that in until later

@bdraco bdraco merged commit bf931f1 into home-assistant:dev Aug 2, 2022
Dev automation moved this from Reviewer approved to Done Aug 2, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Aug 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants