fix: normalize null activity feed payloads (#93)
All checks were successful
CI / lint (pull_request) Successful in 8s
CI / build-frontend (pull_request) Successful in 5s

This commit is contained in:
timmy 2026-08-06 09:46:24 +00:00
parent 43a2804562
commit 6e24d7db17
2 changed files with 15 additions and 1 deletions

View File

@ -47,6 +47,6 @@ async def activity_events() -> list[dict]:
"repo": event.get("repo") or {},
"created_at": event.get("created", ""),
}
for event in events
for event in (events or [])
if isinstance(event, dict)
]

View File

@ -148,3 +148,17 @@ async def test_activity_events_skips_malformed_feed_entries(monkeypatch):
"repo": {"full_name": "stackchain/stackchain-dashboard"},
"created_at": "2026-08-06T08:00:00Z",
}]
@pytest.mark.anyio
async def test_activity_events_normalizes_null_feed_payload(monkeypatch):
async def fake_current_user():
return {"login": "timmy"}
async def fake_fetch(path):
return None
monkeypatch.setattr(gitea_proxy, "current_user", fake_current_user)
monkeypatch.setattr(gitea_proxy, "fetch", fake_fetch)
assert await gitea_proxy.activity_events() == []