aboutsummaryrefslogtreecommitdiff
path: root/webmentions_ssg
diff options
context:
space:
mode:
authorDennis Fink2026-10-30 12:04:22 +0100
committerDennis Fink2026-10-30 12:04:22 +0100
commitd6ac8fb9768352fbb8a5633c6f357d877512bb5f (patch)
treee649a37a7759b093739723a1e299dcc6487b3195 /webmentions_ssg
parent37bc3853dded34e3d1323874927979ce510e4910 (diff)
downloadwebmentions-ssg-d6ac8fb9768352fbb8a5633c6f357d877512bb5f.tar.gz
webmentions-ssg-d6ac8fb9768352fbb8a5633c6f357d877512bb5f.zip
fix(sender): isolate source parser failures
Prevent malformed pages or unexpected third-party parser exceptions from aborting an entire source scan or causing previously known sources to be treated as deleted. Keep persistence failures visible so database errors still fail the scan.
Diffstat (limited to '')
-rw-r--r--webmentions_ssg/tasks/scanner.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/webmentions_ssg/tasks/scanner.py b/webmentions_ssg/tasks/scanner.py
index 5ab2521..4bb6736 100644
--- a/webmentions_ssg/tasks/scanner.py
+++ b/webmentions_ssg/tasks/scanner.py
@@ -459,7 +459,18 @@ def scan_sources() -> None:
base_url=base_url,
ignored_hostnames=ignored_hostnames,
)
+ except (OSError, SourceScanError) as exc:
+ current_app.logger.warning("Could not scan source %s: %s", index_path, exc)
+ continue
+ except Exception:
+ # Third-party HTML parsers can raise unexpected exceptions (including
+ # RecursionError). A bad page must not prevent other sources being saved.
+ current_app.logger.exception(
+ "Unexpected error scanning source %s", index_path
+ )
+ continue
+ try:
if (source := sources_by_path.get(scanned.path)) is None:
source = create_source(scanned, scan_time)
db.session.add(source)
@@ -468,8 +479,7 @@ def scan_sources() -> None:
sources_by_path[source.path] = source
scanned_count += 1
-
- except (OSError, SourceScanError) as exc:
+ except SourceScanError as exc:
current_app.logger.warning("Could not scan source %s: %s", index_path, exc)
for path, source in sources_by_path.items():