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

ip.ok is providing wrong value #453

Open
jabir-khan opened this issue Aug 5, 2022 · 2 comments
Open

ip.ok is providing wrong value #453

jabir-khan opened this issue Aug 5, 2022 · 2 comments

Comments

@jabir-khan
Copy link

hey I was just doing stuff with geocoder and I reeally loved it. However I guess there is some issue in it here is the details:
Screen Shot 2022-08-05 at 8 27 53 AM

As you can see ip.ok is giving True but ip.json.["ok"] is returning False which doesnot satisfy this statement "If geocoder was able to contact the server, but no result could be found for the given search terms, the ok attribute on the returned object will be False." from the docs.

@interDist
Copy link
Contributor

That is because the ok property on the return value tells you (as the docs say) if there is any result, but the IpInfo provider is coded to treat any response from the service as a “result”. It does look like the _adapt_results hook of IpinfoQuery incorrectly processes the response, but it is probably not going to be fixed anytime soon. Our only option is to check both values:

    info = geocoder.ip( ... )
    if info.ok and info.current_result.ok:
        # This means the server could be contacted AND info about the IP could be fetched.

@jabir-khan
Copy link
Author

Gotcha! great thanks.

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

No branches or pull requests

2 participants