fix(triggers): coerce string lastRunAtMs when loading local triggers

This commit is contained in:
santhreal
2026-07-26 23:05:19 +08:00
committed by Xubin Ren
parent 30750060ce
commit 1e505ff405
2 changed files with 40 additions and 1 deletions
+32
View File
@@ -585,3 +585,35 @@ def test_local_trigger_from_dict_accepts_null_run_at_ms() -> None:
)
assert delivery.created_at_ms == 0
assert delivery.attempts == 0
def test_local_trigger_from_dict_coerces_string_last_run_at_ms() -> None:
"""String lastRunAtMs must coerce to int like cron store ms fields."""
trigger = LocalTrigger.from_dict(
{
"id": "t1",
"name": "n",
"enabled": True,
"channel": "websocket",
"chatId": "c1",
"sessionKey": "websocket:c1",
"lastRunAtMs": "1710000000000",
"createdAtMs": 1,
"updatedAtMs": 1,
}
)
assert trigger.last_run_at_ms == 1710000000000
assert trigger.last_run_at_ms < 1710000000001
trigger_null = LocalTrigger.from_dict(
{
"id": "t2",
"name": "n",
"enabled": True,
"sessionKey": "websocket:c1",
"lastRunAtMs": None,
"createdAtMs": 1,
"updatedAtMs": 1,
}
)
assert trigger_null.last_run_at_ms is None