feat(diagnostics): surface raw bytes on protocol detection failure#530
Draft
bluetoothbot wants to merge 2 commits into
Draft
feat(diagnostics): surface raw bytes on protocol detection failure#530bluetoothbot wants to merge 2 commits into
bluetoothbot wants to merge 2 commits into
Conversation
…ails When a device responds with bytes no known protocol can parse (a new firmware/model variant), `_async_determine_protocol` raised a bare "Cannot determine protocol" with no clue what the device actually sent. Users hitting this (issue lightinglibs#402 and related) had nothing actionable to report. Add `_protocol_failure_detail()` which formats any bytes captured during probing — recognized-but-unhandled messages from `_last_message` and the residual unparsed buffer — and include it in both a warning log (with a link to file a report) and the raised exception message. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Surface the raw bytes a device actually sent when
_async_determine_protocolgives up, instead of raising a bare "Cannot determine protocol".
Why
Issue #402 (and several duplicate reports — "Unknown Model 05ADF9", "137BBD",
"1395D3") all hit the same dead end: a device responds with bytes no known
protocol can parse, and the library raises an exception with zero context. The
device's actual response is exactly the data a maintainer needs to add support,
but it was discarded. Users had nothing actionable to file.
How
_protocol_failure_detail()formats whatever was captured during probing:recognized-but-unhandled frames from
_last_messageplus the residual,unparsed
_buffer(the common case for an unrecognized firmware whoseresponse never reaches the expected length).
warninglog (with a link to file a report)and the
DeviceUnavailableExceptionmessage.Testing
case reports "no response received from device".
ruff checkclean.Refs #402
Quality Report
Changes: 2 files changed, 66 insertions(+), 1 deletion(-)
Code scan: clean
Tests: failed (FAILED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline