Skip to content

feat: add utility function to restore bytes from JSON and enhance prefs handling in RepeaterCompanionBridge#275

Open
agessaman wants to merge 1 commit into
pyMC-dev:devfrom
agessaman:fix/binary-persist-1150
Open

feat: add utility function to restore bytes from JSON and enhance prefs handling in RepeaterCompanionBridge#275
agessaman wants to merge 1 commit into
pyMC-dev:devfrom
agessaman:fix/binary-persist-1150

Conversation

@agessaman
Copy link
Copy Markdown
Contributor

@agessaman agessaman commented May 30, 2026

Companion prefs are saved to SQLite as JSON with bytes fields (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 bytes on load and drops the extra self._load_prefs() in __init__, since pymc_core already calls _load_prefs() from the parent during startup.

  • 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.

…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.
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.

1 participant