Skip to content

fix(dbus): dedupe docker vs generic debug logs on connect failure#274

Draft
bluetoothbot wants to merge 2 commits into
Bluetooth-Devices:mainfrom
bluetoothbot:koan/dbus-dedupe-docker-logs
Draft

fix(dbus): dedupe docker vs generic debug logs on connect failure#274
bluetoothbot wants to merge 2 commits into
Bluetooth-Devices:mainfrom
bluetoothbot:koan/dbus-dedupe-docker-logs

Conversation

@bluetoothbot

@bluetoothbot bluetoothbot commented May 27, 2026

Copy link
Copy Markdown
Contributor

What

Make the docker-specific and generic debug hints in _get_dbus_managed_objects mutually exclusive instead of both firing in docker.

Why

In dbus.py, the three connect-error handlers (FileNotFoundError, BrokenPipeError, ConnectionRefusedError) gained a if is_docker_env(): _LOGGER.debug(...) branch in #232 — but the original generic _LOGGER.debug(...) was left in place without an else:. Result: in docker, every connect failure produces two near-duplicate debug lines (one docker-flavored, one generic). Noise during triage.

How

Add else: to the three handlers so each environment surfaces exactly one targeted hint. No behavior change outside docker; pure log dedupe.

Testing

Added test_connect_failure_logs_one_message_per_env — parametrized over the three exception types, runs each twice (docker on/off) and asserts the docker hint appears only in docker, the generic hint only on the host. 54 tests pass, ruff clean, coverage unchanged at 98%.


Quality Report

Changes: 2 files changed, 76 insertions(+), 10 deletions(-)

Code scan: clean

Tests: passed (1
PASSED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

@codecov

codecov Bot commented May 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.61%. Comparing base (ece711c) to head (d3984a3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #274   +/-   ##
=======================================
  Coverage   99.61%   99.61%           
=======================================
  Files          14       14           
  Lines         522      522           
  Branches       48       48           
=======================================
  Hits          520      520           
  Partials        2        2           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@bdraco bdraco requested a review from Copilot May 27, 2026 03:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR deduplicates DBus connection-failure debug hints by making the docker-specific and generic log messages mutually exclusive, and adds a regression test to ensure only the appropriate hint is emitted per environment.

Changes:

  • Add else: branches so only one debug hint is logged for each connect failure type in docker vs non-docker.
  • Add a parametrized async test covering three exception types across docker/non-docker environments.

Reviewed changes

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

File Description
tests/test_init.py Adds a parametrized test asserting docker vs host logging hints don’t overlap.
src/bluetooth_adapters/dbus.py Makes docker-specific vs generic debug logs mutually exclusive via else: branches.

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

Comment thread tests/test_init.py
pass

async def connect(self):
raise exc
Comment thread tests/test_init.py Outdated
Comment on lines +279 to +282
assert docker_only_marker in docker_text
assert generic_marker not in docker_text
assert generic_marker in host_text
assert docker_only_marker not in host_text
@bdraco

bdraco commented May 27, 2026

Copy link
Copy Markdown
Member

@bluetoothbot rr

@bluetoothbot

Copy link
Copy Markdown
Contributor Author

PR Review — fix(dbus): dedupe docker vs generic debug logs on connect failure

Clean, surgical fix for the duplicate-log bug introduced in #232. The else: branches make docker vs generic hints mutually exclusive without altering any other behavior. The parametrized test exercises all three exception types in both environments and asserts marker presence/absence in both directions (docker has docker-marker but not generic, host has generic but not docker), which catches the regression and any future re-introduction. Copilot's two stylistic suggestions (raising exception instances vs classes, asserting on caplog.records vs substring matching) are valid hardening ideas but not blocking — the chosen markers are distinctive enough that substring matching is robust here, and raising the bare class works correctly for these stdlib exceptions. Merge-ready.



Checklist

  • Fix matches stated intent (dedupe logs, no behavior change outside docker)
  • Test covers all three exception types and both env states
  • No untested branches introduced
  • No security/perf concerns

Summary

Clean, surgical fix for the duplicate-log bug introduced in #232. The else: branches make docker vs generic hints mutually exclusive without altering any other behavior. The parametrized test exercises all three exception types in both environments and asserts marker presence/absence in both directions (docker has docker-marker but not generic, host has generic but not docker), which catches the regression and any future re-introduction. Copilot's two stylistic suggestions (raising exception instances vs classes, asserting on caplog.records vs substring matching) are valid hardening ideas but not blocking — the chosen markers are distinctive enough that substring matching is robust here, and raising the bare class works correctly for these stdlib exceptions. Merge-ready.


Automated review by Kōan9a9d09a

bluetoothbot and others added 2 commits May 27, 2026 03:51
When `is_docker_env()` returned True, the three connect-error handlers
(`FileNotFoundError`, `BrokenPipeError`, `ConnectionRefusedError`) emitted
both the docker-specific hint and the generic hint, producing two
near-duplicate debug lines per failure. The generic log was tacked on
without an `else:` branch in Bluetooth-Devices#232.

Make the two logs mutually exclusive so each environment surfaces one
targeted hint. Adds a parametrized test asserting one-message-per-env
across all three exception types.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bluetoothbot

Copy link
Copy Markdown
Contributor Author

Rebase with requested adjustments

Branch koan/dbus-dedupe-docker-logs was rebased onto main and review feedback was applied.

Changes applied

  • Applied both Copilot suggestions.
  • Changes:
  • Instantiated each exception (FileNotFoundError("mock fnf"), etc.) instead of raising the class, per Copilot comment on tests/test_init.py:256.
  • Replaced substring-on-caplog.text assertions with per-record matching against caplog.records. Added local _count() helper that filters to logger bluetooth_adapters.dbus and counts records whose getMessage() contains the marker. Asserts exact counts (docker hint = 1 / generic = 0 in docker; flipped on host), per Copilot comment on tests/test_init.py:282.

Stats

2 files changed, 87 insertions(+), 10 deletions(-)
Actions performed
  • Already-solved check: negative (confidence=high, reasoning=main still lacks the else: guards on all three handlers, so docker environments continue to emit d)
  • Rebased koan/dbus-dedupe-docker-logs onto upstream/main
  • Applied review feedback
  • Pre-push CI check: previous run passed
  • Force-pushed koan/dbus-dedupe-docker-logs to origin
  • CI check enqueued in ## CI (async)

CI status

CI will be checked asynchronously.


Automated by Kōan

@bluetoothbot bluetoothbot force-pushed the koan/dbus-dedupe-docker-logs branch from 9a9d09a to d3984a3 Compare May 27, 2026 03:52
@bdraco bdraco requested a review from Copilot May 27, 2026 03:58

Copilot AI left a comment

Copy link
Copy Markdown

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 2 out of 2 changed files in this pull request and generated no new comments.

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.

3 participants