Attach the response to get_json_safely's HTTPError - #204
Merged
Merged
Conversation
Callers can now check the status code, e.g. to treat 204 No Content (a Census geography with no data for a year) as no rows. 204 is logged as a warning instead of an error. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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
get_json_safelyraisesHTTPErrorfor any non-200 response other than 500 (#202). That includes 204 No Content, which the Census API returns when a request is valid but no data exists. For example, ACS 5-year 2017 lists county subdivision place/remainder parts (070) but has no data for them. Callers couldn't tell that case apart from a real failure, and 204 was logged at ERROR level.Change
HTTPErrorcarriesresponse=r, so callers can checke.response.status_code.test_get_json_safely_http_error_carries_response.morpc-census will use this to treat a 204 as zero rows.
Testing
test_req(3),test_frictionless,test_gpkg,test_morpc,test_release, andtest_geocodeall pass.test_utils: the same 4 datetime tests fail onmain.🤖 Generated with Claude Code