fix(api): reject stale alert cache on hard failure
Some checks failed
CD Pipeline / workflow-shape (push) Successful in 0s
CD Pipeline / cancel-stale-cd (push) Has been skipped
CD Pipeline / tests (push) Successful in 1m14s
CD Pipeline / build-and-deploy (push) Successful in 4m42s
CD Pipeline / post-deploy-checks (push) Has been cancelled

This commit is contained in:
ogt
2026-07-10 22:06:37 +08:00
parent 9b8c7ac254
commit 86ed456682
2 changed files with 21 additions and 12 deletions

View File

@@ -1302,6 +1302,9 @@ def test_ai_alert_card_source_unavailable_response_exposes_ai_repair_queue() ->
async def test_list_ai_alert_card_delivery_readback_failsofts_db_unavailable(
monkeypatch: pytest.MonkeyPatch,
) -> None:
async def stale_cache(**_kwargs):
return {"total": 1, "learning_registry": {}}
class FailingDbContext:
async def __aenter__(self):
raise RuntimeError("db unavailable")
@@ -1319,6 +1322,11 @@ async def test_list_ai_alert_card_delivery_readback_failsofts_db_unavailable(
"_load_ai_alert_card_delivery_readback_direct",
_no_ai_alert_card_direct_readback,
)
monkeypatch.setattr(
platform_operator_service,
"_get_cached_ai_alert_card_delivery_readback",
stale_cache,
)
payload = await platform_operator_service.list_ai_alert_card_delivery_readback(
project_id="awoooi",