fix: clear stale property values on panel reboot to prevent mixed-gen snapshots#130
Merged
cayossarian merged 3 commits intomainfrom Apr 7, 2026
Merged
fix: clear stale property values on panel reboot to prevent mixed-gen snapshots#130cayossarian merged 3 commits intomainfrom
cayossarian merged 3 commits intomainfrom
Conversation
…eration snapshots When the SPAN panel reboots, the MQTT accumulator previously retained pre-reboot property values. This could produce snapshots mixing stale pre-reboot data with fresh post-reboot data during the brief window before all circuits re-publish. The accumulator now conditionally clears property/target/timestamp storage when $description arrives after a lifecycle reset, with a generation counter that invalidates the consumer's snapshot cache. Covers both normal reboots (via LWT $state=disconnected) and fast reboots (via $state=init without LWT). Bumps version to 2.5.2.
There was a problem hiding this comment.
Pull request overview
This PR addresses a SPAN panel reboot edge case where the MQTT accumulator could retain pre-reboot property values, causing snapshots to temporarily mix stale data with fresh post-reboot data. It adds a generation counter to invalidate cached snapshots when a reboot-driven $description triggers a property clear.
Changes:
- Clear accumulated property/target/timestamp state when
$descriptionis received after a lifecycle reset, and increment an accumulator generation counter. - Invalidate
HomieDeviceConsumer’s cached snapshot when the accumulator generation advances. - Add unit tests covering reboot + fast-reboot scenarios and bump project version to
2.5.2.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/span_panel_api/mqtt/accumulator.py |
Clears stale values on reboot-indicated $description, adds generation, and adjusts $state handling. |
src/span_panel_api/mqtt/homie.py |
Invalidates snapshot cache when accumulator generation changes. |
tests/test_accumulator.py |
Adds reboot/fast-reboot tests validating clears + generation behavior. |
tests/test_mqtt_homie.py |
Adds regression test ensuring cache invalidation prevents stale snapshot reuse. |
pyproject.toml |
Bumps package version to 2.5.2. |
uv.lock |
Updates lockfile and package version entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address PR review feedback: - _handle_state else branch now unconditionally sets lifecycle to CONNECTED, fixing a bug where is_ready() could return True when the device was in init/sleeping/alert state - Updated property-clear comment to reflect all reset triggers - Fixed generation docstring to match actual increment semantics
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.
When the SPAN panel reboots, the MQTT accumulator previously retained pre-reboot property values. This could produce snapshots mixing stale pre-reboot data with fresh post-reboot data during the brief window before all circuits re-publish.
The accumulator now conditionally clears property/target/timestamp storage when $description arrives after a lifecycle reset, with a generation counter that invalidates the consumer's snapshot cache. Covers both normal reboots (via LWT $state=disconnected) and fast reboots (via $state=init without LWT).
Bumps version to 2.5.2.