Skip to content

fix(watcher): graceful type-flip degradation + regression tests - #116

Merged
zeevdr merged 1 commit into
mainfrom
feat/type-flip-regression-tests
May 30, 2026
Merged

zeevdr merged 1 commit into
mainfrom
feat/type-flip-regression-tests

Conversation

@zeevdr

@zeevdr zeevdr commented May 30, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixes a crash bug: a server-side type change (e.g. field flips from float to string) would propagate TypeMismatchError uncaught through _apply_raw → _update → _process_change, killing the background subscribe thread/task silently.
  • _apply_raw now catches TypeMismatchError, logs a warning, and resets to the field's registered default value — matching Go SDK behavior.
  • Adds regression tests for sync (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.
  • All three tests pass for both sync (test_watcher.py) and async (test_async_watcher.py) variants.
  • Full test suite: 288 passed, 100% coverage maintained.

Refs opendecree/decree#563

_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 <[email protected]>
@zeevdr zeevdr added this to the Beta Readiness milestone May 30, 2026
@zeevdr zeevdr added size: S Quick win — a few hours or less priority: P2 Nice-to-have labels May 30, 2026
@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zeevdr
zeevdr merged commit a146d9f into main May 30, 2026
15 checks passed
@zeevdr
zeevdr deleted the feat/type-flip-regression-tests branch May 30, 2026 21:06
@github-project-automation github-project-automation Bot moved this from Todo to Done in OpenDecree May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P2 Nice-to-have size: S Quick win — a few hours or less

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant