Tolerate per-URL operational errors instead of aborting the run - #23
Merged
Conversation
A single capture raising an operational error (e.g. Pravda's HAR processing timeout, which Pravda raises rather than persists) propagated out of asyncio.gather and aborted the entire run. Gather these per-URL failures instead: capture_urls now catches exceptions per URL, records them as OperationalError, and returns them alongside the successful captures; the extraction loop does the same. summarise_errors logs a count (by stage and exception type) plus the per-URL detail at the end of the run. The run now completes and writes outputs in spite of these errors. These are operational errors, so they go to the log only — not the database, which is reserved for the capture failures Pravda persists on the snapshot (HTTP status, browser failures). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Make a run tolerate per-URL failures: gather and count them, summarise at the end, and complete regardless.
Why
A
kolkhoz-manualjob aborted mid-run when one URL's capture raised:Pravda deliberately does not persist this kind of failure — its own code notes that inner HAR-processing / storage timeouts are operational errors that it raises, as opposed to HTTP/browser failures which it stores on the snapshot with
errorset. The raised error propagated out ofasyncio.gather(*(snap(url) …))incapture_urlsand took down the entire run, discarding all the work that had already succeeded.Change
capture_urlsnow catches exceptions per URL, logs a warning, records anOperationalError(stage, url, error), and returns(captures, errors). A URL that fails operationally is simply absent from the captures mapping (Pravda-persisted errored snapshots still appear there, unchanged).summarise_errorslogs, at the end of the run, a total plus counts by stage and by exception type, then the per-URL detail.except Exceptionis deliberate breadth for "let the run finish";CancelledError/KeyboardInterruptareBaseExceptionand still propagate.Operational errors go to the log only, not the database — the database stays reserved for the capture failures Pravda persists on the snapshot.
Testing
ruffclean.TimeoutError,capture_urlsreturns the 2 good captures and 2 recorded errors, andsummarise_errorslogs the by-stage/by-type/per-URL summary without raising.🤖 Generated with Claude Code