As of right now today, https://tigerweb.geo.census.gov/ is throwing errors when request are made via IPv6. This module crashes instead of properly handling the error.
The bug is it assumes json. When in fact, their server is returning 200 with html instead.
<html><head><title>Request Rejected</title></head><body>The requested URL was rejected. Please consult with your administrator.<br><br>Your support ID is: 13427891533456682816</body></html>
Here's one way to handle/display the error. After q.raise_for_status() and before attemping q.json():
ct = q.headers.get("Content-Type", "")
if ct.startswith("text/html"):
raise RuntimeError(q.text)
if not ct.startswith("application/json"):
msg = "Unexpected content type for TIGERweb service info"
raise RuntimeError(msg)
You'll need to force IPv6 to reproduce. I've sent a bug report to the TIGERweb admins. So this test case might go away once they fix IPv6.
As of right now today, https://tigerweb.geo.census.gov/ is throwing errors when request are made via IPv6. This module crashes instead of properly handling the error.
cenpy/cenpy/tiger.py
Line 78 in a8deee2
The bug is it assumes json. When in fact, their server is returning 200 with html instead.
Here's one way to handle/display the error. After
q.raise_for_status()and before attempingq.json():You'll need to force IPv6 to reproduce. I've sent a bug report to the TIGERweb admins. So this test case might go away once they fix IPv6.