Browse Source

Fix debug logging endpoint 500 error after version upgrade

  The GET /api/v1/support/debug-logging endpoint returned 500 when the
  database contained a timezone-aware enabled_at timestamp written by
  0.2.2b3. The duration calculation mixed offset-aware and offset-naive
  datetimes, raising TypeError. Strip tzinfo when reading the stored value.
maziggy 2 months ago
parent
commit
253828c2b5
2 changed files with 4 additions and 1 deletions
  1. 3 0
      CHANGELOG.md
  2. 1 1
      backend/app/api/routes/support.py

+ 3 - 0
CHANGELOG.md

@@ -7,6 +7,9 @@ All notable changes to Bambuddy will be documented in this file.
 ### New Features
 - **Home Assistant Notification Provider** ([#656](https://github.com/maziggy/bambuddy/issues/656)) — Added Home Assistant as a notification provider. When HA is configured in Settings → Network → Home Assistant, selecting "Home Assistant" as a notification provider sends persistent notifications to the HA dashboard — no additional configuration needed. From there, HA automations can forward notifications to mobile apps, WhatsApp, or any other service. Requested by @TravisWilder.
 
+### Fixed
+- **Debug Logging Endpoint 500 Error** — The `GET /api/v1/support/debug-logging` endpoint returned a 500 Internal Server Error when the database contained a timezone-aware timestamp written by a previous version. The duration calculation subtracted a timezone-aware datetime from a naive `datetime.now()`, raising `TypeError`. Now strips timezone info when reading the stored timestamp.
+
 
 ## [0.2.2b3] - Unreleased
 

+ 1 - 1
backend/app/api/routes/support.py

@@ -62,7 +62,7 @@ async def _get_debug_setting(db: AsyncSession) -> tuple[bool, datetime | None]:
     enabled_at = None
     if enabled_at_setting and enabled_at_setting.value:
         try:
-            enabled_at = datetime.fromisoformat(enabled_at_setting.value)
+            enabled_at = datetime.fromisoformat(enabled_at_setting.value).replace(tzinfo=None)
         except ValueError:
             pass  # Ignore malformed timestamp; enabled_at stays None