Excessive amount of error 500
See original GitHub issueI’m using this library (v2.0.11) via Home Assistant. My log sees a LOT of error messages that look like this:
Unable to parse response :<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
<title>Error 500 (Server Error)!!1</title>
<style>
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
</style>
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
<p><b>500.</b> <ins>That’s an error.</ins>
<p>The server encountered an error and could not complete your request.<p>If the problem persists, please <A HREF="http://www.google.com/support/">report</A> your problem and mention this error message and the query that caused it. <ins>That’s all we know.</ins>
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.5/site-packages/locationsharinglib/locationsharinglib.py", line 389, in _get_data
data = json.loads(response.text.split("'", 1)[1])
IndexError: list index out of range
They seem to come in bunches. It would be really nice to at least more gracefully handle this exception, like write a small error message to the log that says something like the server could not satisfy the query or something. As it is it looks like the code doesn’t expect this to happen.
It would be even nicer if it could filter out some of the consecutive messages. I did this with one of my HA components. I.e., if the same error happens twice in a row, say in the error message that further errors will not be shown until the errors stop. Then when the query works again, write a message saying things are ok again (maybe even giving a count of how many consecutive errors happened.)
Bottom line, though, is my log gets flooded with these messages and which makes it hard to see other problems that might be happening.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:10 (4 by maintainers)
Hi all,I am currently on vacation and will not be able to work on this until after the 24th. Handling this error better is something that will be done. The library was written in such a way as to force this kind of feedback since it is quite exploratory. The 500 errors could be made into warnings but I don’t think that we should go implementing a state machine for the errors so we rate limit them. I think that specifically the 500 errors sound be made into a warning so it does not spam HA logs but everything else should still break since this is a reverse engineered project and has not been made on top of an official api. There are many possible responses and I think that Google has different services depending on your geo location so I would like to catch everything in time and cover all cases, and masking errors will make it much more difficult.
I think this really requires more than simply hiding these errors.
These errors are causing me massive delays in updates to the location. If I use Google Maps and check the location, it is a maximum of maybe 5-10 minutes old, however using locationsharinglib locations are often an hour old or more. This is while my log fills up with this error message. Previously (before my log starting filling with this error) the update time on locationsharinglib was quite reasonable.
Without a fix for the underlying issue, the usability of this module is severely compromised. Hiding the error message won’t fix that. (Though I will admit that the library should ALSO handle the error more gracefully, a single line in the log is more than enough)