Skip to content

fix(discovery): clean up stuck discovery_running on probe failure (audit companion)#457

Merged
fdebrus merged 1 commit into
mainfrom
claude/discovery-audit-ha
Jun 9, 2026
Merged

fix(discovery): clean up stuck discovery_running on probe failure (audit companion)#457
fdebrus merged 1 commit into
mainfrom
claude/discovery-audit-ha

Conversation

@fdebrus

@fdebrus fdebrus commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

Companion to nikobus-connect #119 (discovery-process audit) — the HA side of the same stuck-flag bug, found independently during my own read of discovery_mixin.py.

In _try_pclink_inventory, the CancelledError path cleared discovery_running and set the finished event — but the generic-exception path returned False with no cleanup. The library sets discovery_running=True before the point where start_inventory_discovery can raise (not connected, send failure), so a probe failure left the flag stuck True: polling suppressed forever (_async_update_data early-returns) and every new scan rejected as "discovery already running". Only an HA restart recovered.

The except path now mirrors the CancelledError cleanup. (0.27.1 also resets library-side on that path — this is the integration's defence in depth for older library versions, and the pin stays >=0.27.0.)

Verification

+1 regression test (probe raises after the library set the flag → flag cleared, event set, fallback still runs). 436 passed, ruff clean, mypy 100 (= baseline).

Independent of #119 — both can merge in any order; publishing 0.27.1 to PyPI after #119 merges gets the library-side fixes to new installs automatically (no pin bump needed).

https://claude.ai/code/session_01LH7yGDY8ttvZUVMVjfSNXj


Generated by Claude Code

…dit companion)

Companion to nikobus-connect#119 (discovery audit). In
_try_pclink_inventory, the CancelledError path cleared
discovery_running and set the finished event, but the generic-exception
path returned False with NO cleanup. The library sets
discovery_running=True before the point where start_inventory_discovery
can raise (not connected, send failure) — so a probe failure left the
flag stuck True: polling suppressed forever and every new scan rejected
as 'discovery already running'. The except path now mirrors the
CancelledError cleanup. (0.27.1 also resets library-side; this is the
integration's defence in depth for older library versions.)

+1 regression test. 436 passed, ruff clean, mypy 100 (= baseline).

https://claude.ai/code/session_01LH7yGDY8ttvZUVMVjfSNXj
@fdebrus fdebrus merged commit 315ad41 into main Jun 9, 2026
8 checks passed
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.

2 participants