From 87117345ed6e99e5a070d919ac17139cba7b8fe4 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Fri, 13 Nov 2026 20:03:49 +0100 Subject: fix(core): make network task failures explicit Introduce a dedicated response-size error so callers only translate expected limit violations instead of masking unrelated `ValueError` exceptions. Ensure failed sockets are always closed, remove dead discovery error handling, and log unexpected sender failures with tracebacks before recording them. --- tests/tasks/test_receiver.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/tasks/test_receiver.py') diff --git a/tests/tasks/test_receiver.py b/tests/tasks/test_receiver.py index 133ab56..51d1bb6 100644 --- a/tests/tasks/test_receiver.py +++ b/tests/tasks/test_receiver.py @@ -198,6 +198,25 @@ def test_fetch_source_rejects_streamed_oversized_body( receiver.fetch_source(SOURCE_URL) +@patch("webmentions_ssg.tasks.receiver.httpx.Client") +def test_fetch_source_does_not_mask_unexpected_value_error( + httpx_client: Mock, + app: Flask, + receiver: ModuleType, + monkeypatch: pytest.MonkeyPatch, +) -> None: + set_stream_response( + httpx_client, + httpx.Response(200, request=httpx.Request("GET", SOURCE_URL)), + ) + monkeypatch.setattr( + receiver, "read_limited_body", Mock(side_effect=ValueError("unexpected bug")) + ) + + with app.app_context(), pytest.raises(ValueError, match="unexpected bug"): + receiver.fetch_source(SOURCE_URL) + + @patch("webmentions_ssg.tasks.receiver.fetch_source") @pytest.mark.parametrize( ("content_type", "body", "expected"), -- cgit v1.3.1