fix(scraper): one chunk failure no longer aborts enrich batch (#47) - #53
Closed
nelsonmfinda wants to merge 1 commit into
Closed
fix(scraper): one chunk failure no longer aborts enrich batch (#47)#53nelsonmfinda wants to merge 1 commit into
nelsonmfinda wants to merge 1 commit into
Conversation
This was referenced May 12, 2026
Owner
|
Best PR of the four, no concerns. Verified empirically: one non transient ProviderError in a five chunk batch leaves four enriched and one dropped, schema fallback success does not poison the primary cache (zero writes when only the fallback succeeded), PROMPT_VERSION derived from One thing worth flagging in your description: this is a hard dependency of #51's |
Owner
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.
Summary
A single chunk's failure no longer aborts the entire concurrent enrich batch.
asyncio.gatherwas called withoutreturn_exceptions=True, so the first non-transientProviderErrorfrom_enrich_onecancelled every in-flight chunk and crashedking-scrapemid-pipeline. After the fix,_enrich_oneis contract-bound never to raise (non-transient errors break the retry loop early and fall through to the schema fallback; everything else is absorbed and the chunk is dropped), andenrich_chunksaddsreturn_exceptions=Trueas a defensive guard with a per-batch summary on stderr.While in there: schema-fallback enrichments are no longer cached under the primary's cache key (was a silent quality regression — next run with the primary healthy would short-circuit at the cache check and serve fallback content), the schema fallback is deduplicated when it points at the same underlying client as the primary's
FallbackClientinner fallback (saves one LLM call per failed chunk in that config), and the bareexcept Exceptionwas narrowed so programming errors propagate instead of hiding as transient retries.Related issue
Closes #47.
Type of change
How it was tested
pytest -q
739 passed, 1 skipped
16 tests in
test_enrich.py(4 rewritten for the new "never raise per chunk" contract, 5 new):ProviderErroron one chunk in a batch of three; the bad chunk drops, the other two enrich, no exception escapesgatherwithreturn_exceptions=Truekeeps siblings alive when one task raises, with a capsys assertion on the per-batch summary lineCancelledErrorreturned bygathertreated as a drop, not a batch abortpytest.raises(ProviderError)now assertresult == []and verify call counts plus the new dedupe behaviourI haven't run a live
king-scrapeagainst a 500+ chunk site in this PR. Happy to do that in review if you want; the unit tests cover the issue's repro precisely.Checklist
pytest)docs/and/orREADME.mdif behavior changed (no public-surface change beyond the user-visible warning lines on stderr; CHANGELOG entry added)