fix(watcher): graceful type-flip degradation + regression tests#116
Merged
Conversation
_apply_raw now catches TypeMismatchError, logs a warning, and falls back to the field's default value (matching Go SDK behavior). Previously a type mismatch from the server would propagate uncaught and crash the background subscribe thread/task. Adds regression tests for both sync (WatchedField, ConfigWatcher) and async (AsyncWatchedField, AsyncConfigWatcher) paths: _load_initial type-flip falls back to default; _update type-flip falls back to default; _process_change type-flip continues the stream. Refs #563 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Summary
floattostring) would propagateTypeMismatchErroruncaught through_apply_raw→_update→_process_change, killing the background subscribe thread/task silently._apply_rawnow catchesTypeMismatchError, logs a warning, and resets to the field's registered default value — matching Go SDK behavior.WatchedField,ConfigWatcher) and async (AsyncWatchedField,AsyncConfigWatcher) paths.Test plan
test_load_initial_type_flip_falls_back_to_default— snapshot with unconvertible value uses default.test_update_type_flip_falls_back_to_default— stream update with unconvertible value uses default.test_type_flip_mid_stream_uses_default_and_continues— bad update resets to default; subsequent valid update still applies.test_watcher.py) and async (test_async_watcher.py) variants.Refs opendecree/decree#563