diff --git a/app/parlamente.py b/app/parlamente.py index 974a514..2f92544 100644 --- a/app/parlamente.py +++ b/app/parlamente.py @@ -3206,7 +3206,10 @@ class SaarlandAdapter(ParlamentAdapter): ) if resp.status_code != 200: logger.error("SL HTTP %s: %s", resp.status_code, resp.text[:200]) - return [] + raise httpx.HTTPStatusError( + f"SL HTTP {resp.status_code}", + request=resp.request, response=resp, + ) data = resp.json() return data.get("FilteredResult", []) or [] except Exception: diff --git a/tests/test_parlamente.py b/tests/test_parlamente.py index 1b181cb..a9d54c3 100644 --- a/tests/test_parlamente.py +++ b/tests/test_parlamente.py @@ -576,3 +576,27 @@ class TestSaarlandSearchPropagatesErrors: with pytest.raises(httpx.ConnectError): asyncio.run(_run()) + + def test_search_propagates_http_500(self): + """HTTP 5xx response must NOT be silently turned into empty results + (regression #142): a 500 from the Umbraco backend used to log+return + [], hiding it from the monitoring summary.""" + import httpx + from app.parlamente import SaarlandAdapter + + adapter = SaarlandAdapter() + + async def _run(): + mock_client = AsyncMock() + mock_client.__aenter__ = AsyncMock(return_value=mock_client) + mock_client.__aexit__ = AsyncMock(return_value=False) + mock_resp = MagicMock() + mock_resp.status_code = 500 + mock_resp.text = "Server Error" + mock_resp.request = MagicMock() + mock_client.post = AsyncMock(return_value=mock_resp) + with patch.object(adapter, "_make_client", return_value=mock_client): + await adapter.search("Schule") + + with pytest.raises(httpx.HTTPStatusError): + asyncio.run(_run())