OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

Fix watch scheduler comparison of timezone-aware and naive datetimes

Open neurosovereign opened this issue 4 months ago • 0 comments

Bug

The resource watch scheduler can stop with:

TypeError: can't compare offset-naive and offset-aware datetimes

Persisted watch tasks may contain offset-aware timestamps such as 2026-07-09T04:14:37+08:00, while the scheduler uses naive datetime.now() values in due-task comparisons and sleep-duration calculations.

Affected paths include:

  • openviking/resource/watch_manager.py
  • openviking/resource/watch_scheduler.py

Impact

The scheduler fails to check due tasks and can terminate its background loop, preventing watched resources from refreshing.

Proposed fix

Use UTC-aware timestamps consistently, normalize legacy naive/offset timestamps when loading persisted watch tasks, and persist the normalized representation. Add regression tests for aware, UTC, and legacy-naive timestamps.

A working focused fix is available in the accompanying draft PR.

neurosovereign avatar Jul 15 '26 11:07 neurosovereign