Fix Pulse flusher state writes#2
Merged
Merged
Conversation
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
There was a problem hiding this comment.
Pull request overview
Fixes Pulse state flusher failures caused by JSON key sorting on mixed/unorderable key types, and improves thread-safety around state persistence.
Changes:
- Stop sorting JSON keys on state writes and make JSON serialisation failures non-fatal (log + continue).
- Add locked storage snapshots for flushes and tighten locking around feed/seen mutations.
- Add regression tests and repository maintenance/CI hygiene files (labeler, templates, contributing doc).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
plugin.py |
Removes sort_keys=True, adds non-fatal JSON serialisation handling, flushes via storage snapshot. |
storage.py |
Adds deep-copied snapshot method and expands locking/copying for feed/seen state access. |
test.py |
Adds regression tests for snapshot isolation and non-raising flush/write behaviour. |
docs/CONTRIBUTING.md |
Adds contributing/recognition guidance. |
.gitignore |
Removes ignored To-Do file entry. |
.github/workflows/labeler.yml |
Adds PR labeler workflow. |
.github/labeler.yml |
Adds label rules for common areas (plugin/docs/tests/etc.). |
.github/PULL_REQUEST_TEMPLATE.md |
Adds PR template checklist and guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
129
to
+133
| try: | ||
| with open(path, "w", encoding="utf-8") as handle: | ||
| json.dump(data, handle, indent=2, sort_keys=True) | ||
| json.dump(data, handle, indent=2) | ||
| except (TypeError, ValueError) as e: | ||
| log.warning(f"Pulse: could not serialise {path}: {e}") |
Comment on lines
+56
to
60
| for name, record in self.feeds[LEGACY_FEEDS_NETWORK].items() | ||
| if looks_like_feed_record(record) | ||
| } | ||
| return self.feeds.setdefault(network, {}) | ||
|
|
Comment on lines
61
to
+65
| def get_feed_record(self, network, name): | ||
| return self.network_feeds(network).get(callbacks.canonicalName(name)) | ||
| record = self.network_feeds(network).get(callbacks.canonicalName(name)) | ||
| if record is None: | ||
| return None | ||
| return dict(record) |
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.
Pull Request
Summary
Fixes Pulse’s Limnoria flusher failure on Borg where json.dump(..., sort_keys=True) raised:
TypeError: '<' not supported between instances of 'dict' and 'dict'Changes
JSONstate writes so mixed/unorderable keys do not break flushing.JSONserialisation errors during state writes.JSONwrites with unsortable key typesVerification
python -m pytest -q: 19 passedpython -m py_compile ...: passedtracked file-by-file Black check: passedgit diff --check: passed