feat: add utility function to restore bytes from JSON and enhance prefs handling in RepeaterCompanionBridge#275
Open
agessaman wants to merge 1 commit into
Open
Conversation
…fs handling in RepeaterCompanionBridge - Introduced `_prefs_bytes_from_json` to convert JSON hex strings back to bytes for NodePrefs fields. - Updated `_load_prefs` logic to handle bytes conversion when loading preferences. - Improved the handling of preferences in the `RepeaterCompanionBridge` class to ensure proper type restoration.
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.
Companion prefs are saved to SQLite as JSON with
bytesfields (e.g.default_scope_key) hex-encoded, but on load upstream restores them as plain strings. After restart,get_default_flood_scope()fails (TypeError: string argument without an encoding) and scoped flood routing no longer works.This PR decodes hex back to
byteson load and drops the extraself._load_prefs()in__init__, since pymc_core already calls_load_prefs()from the parent during startup._prefs_bytes_from_jsonto convert JSON hex strings back to bytes for NodePrefs fields._load_prefslogic to handle bytes conversion when loading preferences.RepeaterCompanionBridgeclass to ensure proper type restoration.