Surface programming errors in user fetches
ci / push-image (push) Successful in 1m14s
ci / deploy-coolify (push) Successful in 7s
ci / test (push) Successful in 36s

This commit is contained in:
Space-Banane
2026-06-04 22:56:11 +02:00
parent c622420e38
commit c94bc7e5d4
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -162,7 +162,7 @@ async def _fetch_source_username(
) -> tuple[str, tuple[dict[str, int], bool] | Exception]: ) -> tuple[str, tuple[dict[str, int], bool] | Exception]:
try: try:
return username, await _fetch_with_cache(cache, key, fetcher) return username, await _fetch_with_cache(cache, key, fetcher)
except Exception as exc: except (GitHubSourceError, GiteaSourceError) as exc:
return username, exc return username, exc
+19
View File
@@ -65,6 +65,25 @@ async def test_fetch_source_usernames_skips_failed_accounts() -> None:
assert stale is False assert stale is False
@pytest.mark.asyncio
async def test_fetch_source_usernames_does_not_swallow_programming_errors() -> None:
def broken_fetcher(username):
async def fetch():
raise TypeError("bad shape")
return fetch
with pytest.raises(TypeError, match="bad shape"):
await _fetch_source_usernames(
None,
"github",
["octocat", "hubot"],
date(2026, 1, 1),
date(2026, 1, 1),
broken_fetcher,
)
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_fetch_source_usernames_keeps_cache_after_username_list_changes() -> None: async def test_fetch_source_usernames_keeps_cache_after_username_list_changes() -> None:
with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir: with tempfile.TemporaryDirectory(dir=Path.cwd()) as temp_dir: