Here's a list of addresses:
1109 N Highland St, Arlington VA
1600 Pennsylvania Ave NW, Washington DC
qwertyuiop asdfghjkl zxcvbnm
One is obvious junk. If I just hit the API with this batch, I get back:
[
{'query': '1109 N Highland St, Arlington VA', 'response': {'results': [ ... ]}},
{'query': '1600 Pennsylvania Ave NW, Washington DC', 'response': { 'results': [ ... ]}},
{'query': 'qwertyuiop asdfghjkl zxcvbnm', 'response': {
'error': 'Could not geocode address. No matches found.',
'reference': 'https://www.geocod.io/geocodio-422-unprocessable-entity/',
'results': []
}
}
]
But when I try the same thing with the library (e.g. result = client.geocode(batch)), it throws an error.
Traceback (most recent call last):
File "/.../geocodio-library-bugs/repro.py", line 143, in bug_1_batch_chokes_on_invalid_address
result = client.geocode(batch)
^^^^^^^^^^^^^^^^^^^^^
File "/.../geocodio-library-bugs/.venv/lib/python3.12/site-packages/geocodio/client.py", line 228, in geocode
return self._parse_geocoding_response(response.json())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/.../geocodio-library-bugs/.venv/lib/python3.12/site-packages/geocodio/client.py", line 385, in _parse_geocoding_response
res["response"]["results"][0]["address_components"]
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
The junk address in this example would be easy to detect and throw out before sending a batch, but there's no a priori way to know if an address string will come back invalid; this was discovered using real world address data in a civic dataset.
Here's a list of addresses:
One is obvious junk. If I just hit the API with this batch, I get back:
But when I try the same thing with the library (e.g.
result = client.geocode(batch)), it throws an error.The junk address in this example would be easy to detect and throw out before sending a batch, but there's no a priori way to know if an address string will come back invalid; this was discovered using real world address data in a civic dataset.