Repository navigation
--allow-empty writes an empty file only for a genuine empty; no job data is exit 4 only when the site says so - #11
Merged
Conversation
…ata is exit 4 only when the site says so finish_run now writes an empty result ([] plus a header-only CSV and a status "empty" sidecar) only for a finished, unblocked run; a blocked or failed run keeps its exit code, writes no row file and leaves earlier output and its sidecar untouched, and diff_runs accepts "empty". A final page with no job data is a genuine empty only when its payload's own container is present and empty under a 2xx. A served page that never became the payload is parser_found_nothing (exit 5, or 6 after rows), and an unexplained non-2xx is target_http_error (exit 5/6). Same in all three engines and scraper_api_client.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CKsd7q25N19WzUZjrAdzx8
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.
Problem
There were two remaining holes in how this repo reports a run that finds nothing.
--allow-emptydestroyed the output it exists to protect. With the flag, a blocked or failed run wrote[]over earlier good output, plus afailedsidecar. This was confirmed by callingfinish_run. A genuine empty run was also labelledfailed, anddiff_runs.pyrefused to compare it.completed. This happened in several ways:unknown, counted as a read page with zero rows. All three engines then reported an empty result, and so didscraper_api_client.py.Resulting behaviour
finish_runcarries the same patch as woolworths, weibo and wellfound:--allow-empty[]+ header-only CSVstatus: emptyblocked/failedonly when nothing earlier exists and the flag is setpartialdiff_runs.pycompares anemptyrun like a complete one.No job data is exit 4 only when the page is a 2xx and its payload's own container is present and empty (the
emptystate):unknownafter its retries, andparse_error. The result isparser_found_nothing: exit 5, or 6 after rows, with the page inpages_unreadable.target_http_error: exit 5, or 6 after rows. The status goes intopages_target_http_error, and the page is not retried. 5xx keepstarget_http_5xxand its retries.scraper_api_client.py. The API client'sparse_errornow goes throughfinish_runinstead of returning a bare 5.Evidence
New checks:
check_allow_empty_writes_only_a_genuine_empty_result: the same scenario set as the siblings. It includes byte-for-byte preservation for blocked, never obtained and parser failure, and thediff_runsacceptance.check_no_job_data_is_exit_4_only_when_the_site_says_so: each engine's realscrape()with the browser primitives stubbed. It runs:empty;target_http_error,{"1": 400}and one fetch;parser_found_nothing;pages_unreadable: [2].main(), withrequests.poststubbed.--allow-emptysidecar is now expected to sayblocked.Planted-fault controls (Playwright venv). Each one went red, and the suite was green again after restore:
output_writeranddiff_runsfrom main, 14 failures.genuine_empty = not rows.failed.diff_runsback to!= "complete".unknowncounted as read. The engines gave exit 4completed/single_page_routeand exit 0 for rows then no data.parse_erroras a failure, giving exit 4.Suites:
ci_checks.py --allwas OK.No paid calls, no proxies and no credentials were used.
Not changed
Retry-Afterhandling.🤖 Generated with Claude Code
https://claude.ai/code/session_01CKsd7q25N19WzUZjrAdzx8