Skip to content

fix: raise errors for unsuccessful Address Validation responses - #6

Draft
illuminati1911 wants to merge 1 commit into
masterfrom
address-validation-errors
Draft

illuminati1911 wants to merge 1 commit into
masterfrom
address-validation-errors

Conversation

@illuminati1911

Copy link
Copy Markdown
Collaborator

Summary

  • Raise ApiError with Google's structured status and message for unsuccessful Address Validation responses.
  • Fall back to HTTPError for non-JSON or malformed error bodies instead of returning error payloads or leaking JSON decoding errors.
  • Preserve successful JSON responses and existing retry behavior; HTTP 429 retry policy is unchanged.
  • Replace the URL-only test with error-handling regression coverage, remove obsolete commented-out handling, and add a changelog entry.

The existing extractor returns parsed JSON without checking the HTTP status: https://github.com/googlemaps/google-maps-services-python/blob/d3b71ab1333cff0f900d2db6b39c1356341a5ea2/googlemaps/addressvalidation.py#L25-L44

Structured error parsing follows Google's HTTP/JSON error format: https://google.aip.dev/193#http11json-representation

Verification

  • Python 3.10: python -m pytest tests/test_addressvalidation.py — 5 passed.
  • Python 3.10: python -m pytest — 109 passed.
  • Reproduced the original behavior before the fix and confirmed the correction afterward with locally intercepted requests and live sockets blocked.
  • Also exercised the committed fix over real loopback HTTP: structured 400 errors, non-JSON 403 errors, 503 retry followed by a successful result, and terminal 429 handling. No Google Maps requests or real credentials were used.
  • nox --download-python never -s docs --force-python 3.10 — passed. Visually inspected generated Sphinx documentation and the rendered changelog in Chromium.
  • The prescribed Python 3.7 docs build remains unverified because Python 3.7 is unavailable on this machine. The Python 3.10 build is supplemental.
  • Pytest ran directly with the repository's test dependencies to avoid the Nox follow-on Codecov upload.

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