Repository navigation
fix: make the refresh_tree() cascade best-effort - #42
Merged
Merged
Conversation
Property.publish_value() reaches the MQTT client without wrapping it and Node.publish() had no guard, so a bring-your-own-transport client that raised on a single property aborted the walk from wherever it failed. That took out every later sibling, every ancestor's $state publish, and therefore the whole tree's reconnect: one sick device could keep an entire enclosure off the broker. Contain it at two grains: per property in Node.publish(), and per child in the refresh_tree() recursion. Reconnect is exactly when a partial refresh beats an aborted one. The policy is now stated in the docstring instead of being an accident of which methods happened to have a try/except; the exception is logged (reason=deviceRefreshTreeChildFailed / nodePublishPropertyFailed) and not re-raised. Closes #36. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
dcj
force-pushed
the
fix/refresh-tree-best-effort
branch
from
August 7, 2026 14:33
a3d5422 to
b9a15b4
Compare
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.
Closes #36.
Device.publish()wraps its body, so the paths people usually hit are covered.Property.publish_value()does not, andNode.publish()had no guard, so an injected transport that raises on one property aborted the cascade from wherever it failed.The blast radius is larger than it looks. Because #32 moved a device's own
$stateto after the recursion, an exception escaping a child now also suppresses the parent's state publish. So a single raising property could take out:$state, all the way to the rootwhich is the entire tree's reconnect, from one sick device.
The policy
Best-effort, contained at two grains: per property in
Node.publish(), and per child in therefresh_tree()recursion. Reconnect is precisely when a partial refresh beats an aborted one. Logged asreason=nodePublishPropertyFailed/reason=deviceRefreshTreeChildFailed, not re-raised.The point is less the try/except than that the behaviour is now stated in the
refresh_tree()docstring, rather than being an accident of which methods happened to have a guard.Tests
test_refresh_tree_continues_past_a_raising_child: a sibling ordered after the failure still republishes, and the parent still announces$state.test_node_publish_continues_past_a_raising_property: a sibling property still publishes and the device still announces.Both fail on main with the RuntimeError propagating out.
550 passed.