Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return an error tuple when a non-JSON response is received #34

Merged
merged 1 commit into from
Jul 19, 2022

Conversation

s3cur3
Copy link
Contributor

@s3cur3 s3cur3 commented Jul 19, 2022

First, let me say thanks for publishing such a useful "small, sharp tool" of a library. We've been happily using it in production for awhile now. ☺️

We saw an issue today where our geo IP provider had an outage and was rendering an HTML error page, rather than sending the expected JSON request. With this PR, GeoIP.lookup/1 will return an error tuple in that case rather than raising an exception.

Stacktrace from the issue we saw:

** (Jason.DecodeError) unexpected byte at position 0: 0x3C ("<")
    (jason 1.3.0) lib/jason.ex:92: Jason.decode!/2
    (geoip 0.2.7) lib/geoip/lookup.ex:56: GeoIP.Lookup.parse_response/1
    (geoip 0.2.7) lib/geoip/lookup.ex:23: GeoIP.Lookup.lookup/1

We saw an issue in production where our geo IP provider had an outage and was rendering an HTML error page, rather than sending the expected JSON request. With this PR, GeoIP.lookup/1 will return an error tuple rather than raising an exception.

Stacktrace from the issue we saw:

** (Jason.DecodeError) unexpected byte at position 0: 0x3C ("<")
    (jason 1.3.0) lib/jason.ex:92: Jason.decode!/2
    (geoip 0.2.7) lib/geoip/lookup.ex:56: GeoIP.Lookup.parse_response/1
    (geoip 0.2.7) lib/geoip/lookup.ex:23: GeoIP.Lookup.lookup/1
@coveralls
Copy link

Pull Request Test Coverage Report for Build a5df028a28e11426492f45e222f56d9bfb8df2f5-PR-34

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 91.667%

Totals Coverage Status
Change from base Build d17095e9c78ea9b1e991c93c9123a0a2da20ab88: 0.2%
Covered Lines: 33
Relevant Lines: 36

💛 - Coveralls

@iloveitaly
Copy link
Collaborator

Great! Thank you.

@iloveitaly iloveitaly merged commit 544fffb into navinpeiris:master Jul 19, 2022
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.

3 participants