omi icon indicating copy to clipboard operation
omi copied to clipboard

Python SDK BLE callback wrappers silently ignore supported awaitables

Open e13balwinder opened this issue 2 months ago • 2 comments

AsyncPacketHandler allows an Awaitable[None], but listen() and listen_payload() check callback results with asyncio.iscoroutine(). A callback returning a custom awaitable is called but its asynchronous body never runs; a returned Future is not awaited, so pending work and Future exceptions are skipped by the wrapper. Reproduced against main commit 7163538913e15dd86534b41dc695e2a5639c0774, using the real SDK module and a mocked BleakClient, without a physical device or external service.

Affected code: callback type and listen(), listen_payload(). Python provides inspect.isawaitable() for the declared return contract.

I have prepared a local fix for both checks and behavioural tests in the existing SDK test file. The same 29-test SDK suite gives 10 failed / 19 passed on unchanged source and 29 passed with the fix. Coverage includes synchronous callbacks, native coroutines, custom awaitables, pending/completed Futures, exception propagation and existing packet-header handling. BLE transport is mocked; no claim of hardware validation.

@josancamon19 @kodjima33, would you consider a $25 bounty for this fix under the documented PayPal process, payable after an accepted PR is merged? The work is AI-assisted and has been independently reviewed and rerun locally. I will prepare the repository preflight checks before submitting a PR if this is useful.

e13balwinder avatar Sep 07 '26 21:09 e13balwinder

@josancamon19 I can take an independent current-main implementation for US$15, payable through the documented private PayPal process after acceptance and merge. I would replace the two coroutine-only checks with the declared awaitable contract, then add focused coverage for synchronous callbacks, native coroutines, Futures, custom awaitables, and propagated exceptions while keeping BLE transport mocked. I would not claim physical BLE validation. Please confirm funding and eligibility; I am not assuming assignment or payment.

haotvko avatar Sep 11 '26 13:09 haotvko

I'd like to work on this issue. I'll open a PR shortly.

juliofarah avatar Sep 11 '26 19:09 juliofarah