From 14e8e512f254b98a0086e8268db6f072ed9ff4a1 Mon Sep 17 00:00:00 2001 From: maziggy Date: Tue, 27 Jan 2026 15:21:32 +0100 Subject: [PATCH] Fix timezone comparison in GitHub backup scheduler The scheduler compared timezone-aware datetime.now(UTC) with naive datetimes from the SQLite database, causing "can't compare offset-naive and offset-aware datetimes" error. Fixed by adding UTC timezone to naive datetimes before comparison. --- backend/app/services/github_backup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/services/github_backup.py b/backend/app/services/github_backup.py index d767863fe..e7e1bfb1f 100644 --- a/backend/app/services/github_backup.py +++ b/backend/app/services/github_backup.py @@ -87,7 +87,11 @@ class GitHubBackupService: now = datetime.now(UTC) for config in configs: - if config.next_scheduled_run and config.next_scheduled_run <= now: + # Handle both naive (from DB) and aware datetimes + next_run = config.next_scheduled_run + if next_run and next_run.tzinfo is None: + next_run = next_run.replace(tzinfo=UTC) + if next_run and next_run <= now: logger.info(f"Running scheduled backup for config {config.id}") await self.run_backup(config.id, trigger="scheduled")