Просмотр исходного кода

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 месяцев назад
Родитель
Сommit
d374e5f70b
2 измененных файлов с 15 добавлено и 0 удалено
  1. 6 0
      CHANGELOG.md
  2. 9 0
      backend/app/api/routes/support.py

+ 6 - 0
CHANGELOG.md

@@ -7,12 +7,18 @@ All notable changes to Bambuddy will be documented in this file.
 ### New Features
 ### 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.
 - **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.
 
 
+<<<<<<< HEAD
 <<<<<<< HEAD
 <<<<<<< HEAD
 ### Fixed
 ### 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.
 - **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.
 
 
 =======
 =======
 >>>>>>> aab695c (  Add Home Assistant as notification provider (#656))
 >>>>>>> aab695c (  Add Home Assistant as notification provider (#656))
+=======
+### 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.
+
+>>>>>>> 63ca668 (  Fix debug logging endpoint 500 error after version upgrade)
 
 
 ## [0.2.2b3] - Unreleased
 ## [0.2.2b3] - Unreleased
 
 

+ 9 - 0
backend/app/api/routes/support.py

@@ -62,6 +62,7 @@ async def _get_debug_setting(db: AsyncSession) -> tuple[bool, datetime | None]:
     enabled_at = None
     enabled_at = None
     if enabled_at_setting and enabled_at_setting.value:
     if enabled_at_setting and enabled_at_setting.value:
         try:
         try:
+<<<<<<< HEAD
 <<<<<<< HEAD
 <<<<<<< HEAD
             enabled_at = datetime.fromisoformat(enabled_at_setting.value).replace(tzinfo=None)
             enabled_at = datetime.fromisoformat(enabled_at_setting.value).replace(tzinfo=None)
 =======
 =======
@@ -69,6 +70,14 @@ async def _get_debug_setting(db: AsyncSession) -> tuple[bool, datetime | None]:
             if enabled_at.tzinfo is None:
             if enabled_at.tzinfo is None:
                 enabled_at = enabled_at.replace(tzinfo=timezone.utc)
                 enabled_at = enabled_at.replace(tzinfo=timezone.utc)
 >>>>>>> 63208cf (  Fix debug logging banner showing negative timer duration)
 >>>>>>> 63208cf (  Fix debug logging banner showing negative timer duration)
+=======
+            enabled_at = datetime.fromisoformat(enabled_at_setting.value)
+            if enabled_at.tzinfo is None:
+                enabled_at = enabled_at.replace(tzinfo=timezone.utc)
+=======
+            enabled_at = datetime.fromisoformat(enabled_at_setting.value).replace(tzinfo=None)
+>>>>>>> 253828c (  Fix debug logging endpoint 500 error after version upgrade)
+>>>>>>> 63ca668 (  Fix debug logging endpoint 500 error after version upgrade)
         except ValueError:
         except ValueError:
             pass  # Ignore malformed timestamp; enabled_at stays None
             pass  # Ignore malformed timestamp; enabled_at stays None