Skip to content

Attach the response to get_json_safely's HTTPError - #204

Merged
jinskeep-morpc merged 1 commit into
mainfrom
fix/http-error-response
Sep 23, 2026
Merged

jinskeep-morpc merged 1 commit into
mainfrom
fix/http-error-response

Conversation

@jinskeep-morpc

Copy link
Copy Markdown
Collaborator

Problem

get_json_safely raises HTTPError for 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

  • The raised HTTPError carries response=r, so callers can check e.response.status_code.
  • 204 is logged as a warning ("No content returned") instead of an error. Behaviour is otherwise unchanged: 204 still raises.
  • New test: 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, and test_geocode all pass.
  • test_utils: the same 4 datetime tests fail on main.

🤖 Generated with Claude Code

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>
@jinskeep-morpc
jinskeep-morpc merged commit c31959b into main Sep 23, 2026
1 check passed
@jinskeep-morpc jinskeep-morpc mentioned this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant