From 04c7bb1c9700a964355e8232147c0e80a191495c Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 13 May 2026 12:27:58 +0800 Subject: [PATCH] fix(awooop): store outbound sent timestamp as naive utc --- apps/api/src/services/channel_hub.py | 6 +++++- apps/api/tests/test_channel_hub_grouped_alert_events.py | 1 + docs/LOGBOOK.md | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/api/src/services/channel_hub.py b/apps/api/src/services/channel_hub.py index e6903986..5b8e7c65 100644 --- a/apps/api/src/services/channel_hub.py +++ b/apps/api/src/services/channel_hub.py @@ -489,7 +489,11 @@ async def record_outbound_message( source_envelope_json = json.dumps(envelope, ensure_ascii=False, default=str) actual_status = "shadow" if is_shadow else send_status - sent_at = datetime.now(UTC) if actual_status == "sent" else None + sent_at = ( + datetime.now(UTC).replace(tzinfo=None) + if actual_status == "sent" + else None + ) await ensure_completed_shadow_run( db, diff --git a/apps/api/tests/test_channel_hub_grouped_alert_events.py b/apps/api/tests/test_channel_hub_grouped_alert_events.py index cd1714b6..02f08ea4 100644 --- a/apps/api/tests/test_channel_hub_grouped_alert_events.py +++ b/apps/api/tests/test_channel_hub_grouped_alert_events.py @@ -135,3 +135,4 @@ async def test_record_outbound_message_sets_sent_at_for_sent_messages() -> None: assert ":sent_at" in insert_statement assert session.param_sets[-1]["send_status"] == "sent" assert session.param_sets[-1]["sent_at"] is not None + assert session.param_sets[-1]["sent_at"].tzinfo is None diff --git a/docs/LOGBOOK.md b/docs/LOGBOOK.md index 20d24276..c9192f7e 100644 --- a/docs/LOGBOOK.md +++ b/docs/LOGBOOK.md @@ -7308,5 +7308,6 @@ OK - rollback transaction smoke 抓到 asyncpg bind parameter 型別推論問題:`CASE WHEN :send_status = 'sent'` 會被推成 text/varchar ambiguous。 - 第一版 `CAST(:send_status AS text)` 仍會因同一 bind param 同時插入 varchar 與比較而 ambiguous;最終改成 Python 端計算 `sent_at` 參數,SQL 只插入 `:sent_at`,避免 outbound mirror 在 production 寫入時失敗。 +- 第二次 rollback smoke 抓到 DB 欄位是 `timestamp without time zone`,已改成 naive UTC `datetime.now(UTC).replace(tzinfo=None)`,避免 asyncpg timezone-aware bind 失敗。 **目前整體進度**:約 69%。