Skip to content

Allow empty notification when using "AcquireNotify"#1983

Open
dlech wants to merge 2 commits intohbldh:developfrom
dlech:bluez-empty-notification
Open

Allow empty notification when using "AcquireNotify"#1983
dlech wants to merge 2 commits intohbldh:developfrom
dlech:bluez-empty-notification

Conversation

@dlech
Copy link
Copy Markdown
Collaborator

@dlech dlech commented May 5, 2026

Drop the check for empty data in the "AcquireNotify" callback. Normally in Python, read() returning an empty bytes object indicates EOF. In this case, it just means that a notification with an empty payload was received, which is perfectly valid.

Fixes: #1982

Add parametrization to test start_notify() with both use_start_notify
True and False on Linux. These have significantly different code paths.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.45%. Comparing base (8ba2718) to head (bdbbf89).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1983      +/-   ##
===========================================
+ Coverage    52.06%   52.45%   +0.38%     
===========================================
  Files           43       43              
  Lines         4091     4097       +6     
  Branches       503      504       +1     
===========================================
+ Hits          2130     2149      +19     
+ Misses        1830     1817      -13     
  Partials       131      131              
Flag Coverage Δ
bluez-integration-py3.10 39.15% <100.00%> (+0.40%) ⬆️
bluez-integration-py3.11 39.15% <100.00%> (+0.40%) ⬆️
bluez-integration-py3.12 39.15% <100.00%> (+0.40%) ⬆️
bluez-integration-py3.13 39.15% <100.00%> (+0.40%) ⬆️
bluez-integration-py3.14 37.64% <100.00%> (+0.41%) ⬆️
macos-latest-py3.10 20.03% <0.00%> (-0.03%) ⬇️
macos-latest-py3.11 20.03% <0.00%> (-0.03%) ⬇️
macos-latest-py3.12 20.03% <0.00%> (-0.03%) ⬇️
macos-latest-py3.13 20.03% <0.00%> (-0.03%) ⬇️
macos-latest-py3.14 19.84% <0.00%> (-0.03%) ⬇️
ubuntu-latest-py3.10 23.94% <14.28%> (-0.02%) ⬇️
ubuntu-latest-py3.11 23.94% <14.28%> (-0.02%) ⬇️
ubuntu-latest-py3.12 23.94% <14.28%> (-0.02%) ⬇️
ubuntu-latest-py3.13 23.94% <14.28%> (-0.02%) ⬇️
ubuntu-latest-py3.14 22.05% <14.28%> (-0.01%) ⬇️
windows-latest-py3.10 18.72% <0.00%> (-0.03%) ⬇️
windows-latest-py3.11 18.72% <0.00%> (-0.03%) ⬇️
windows-latest-py3.12 18.72% <0.00%> (-0.03%) ⬇️
windows-latest-py3.13 18.72% <0.00%> (-0.03%) ⬇️
windows-latest-py3.14 18.44% <0.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to allow valid zero-length payloads to pass through the BlueZ AcquireNotify path instead of being treated as an error, addressing issue #1982 in the Linux backend.

Changes:

  • Removed the explicit empty-read check in the BlueZ notification fd reader.
  • Expanded integration notification/indication tests to exercise both StartNotify and AcquireNotify paths on BlueZ.
  • Added an integration test for empty notification payload delivery and documented the fix in the changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
bleak/backends/bluezdbus/client.py Adjusts AcquireNotify fd read handling for empty payloads.
tests/integration/test_client_characteristics.py Broadens notification test coverage and adds an empty-payload notification test.
CHANGELOG.rst Documents the BlueZ empty-notification fix under Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread bleak/backends/bluezdbus/client.py Outdated
Comment thread tests/integration/test_client_characteristics.py
@dlech dlech force-pushed the bluez-empty-notification branch 4 times, most recently from b140a54 to 9a64167 Compare May 5, 2026 19:51
…reNotify

Drop the check for empty data in the AcquireNotify callback. Normally
in Python, read() returning an empty bytes object indicates EOF. In this
case, it just means that a notification with an empty payload was
received, which is perfectly valid.

Fixes: hbldh#1982
@dlech dlech force-pushed the bluez-empty-notification branch from 9a64167 to bdbbf89 Compare May 5, 2026 19:52
@dlech dlech requested a review from Copilot May 5, 2026 19:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Empty notification support when using "AcquireNotify"

2 participants