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. --- webmentions_ssg/tasks/sender.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'webmentions_ssg/tasks/sender.py') diff --git a/webmentions_ssg/tasks/sender.py b/webmentions_ssg/tasks/sender.py index db99476..cd6c64a 100644 --- a/webmentions_ssg/tasks/sender.py +++ b/webmentions_ssg/tasks/sender.py @@ -210,10 +210,8 @@ def send_webmention_task(webmention_uuid: uuid.UUID) -> None: httpx.InvalidURL, httpx.UnsupportedProtocol, httpx.LocalProtocolError, - ValueError, - UnicodeError, ) as exc: - # Invalid URLs and local protocol errors cannot improve with retries. + # Known permanent failures cannot improve with retries. outcome = SentWebmentionStatus.FAILED reason = str(exc) or type(exc).__name__ except (TemporarySenderError, AddressResolutionError, httpx.RequestError) as exc: @@ -221,6 +219,14 @@ def send_webmention_task(webmention_uuid: uuid.UUID) -> None: reason = str(exc) or "Webmention request failed" terminal = attempt >= max_attempts temporary_failure = True + except Exception as exc: + # Unexpected errors must not disappear into a generic permanent-failure + # handler without a traceback (including programming ValueErrors). + current_app.logger.exception( + "Unexpected error sending SentWebmention %s", webmention_uuid + ) + outcome = SentWebmentionStatus.FAILED + reason = str(exc) or type(exc).__name__ # A scanner may have reopened or superseded the revision during I/O. # Refresh only once, and persist one outcome atomically with its metadata. -- cgit v1.3.1