-
Notifications
You must be signed in to change notification settings - Fork 86
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
Error on Check_and_refresh_token #62
Comments
This started happening to me today at the same time that the Kia Connect app reported that my account had exceeded the maximum number of daily checks. I'm changing my monitoring app to turn down the polling frequency to every 30 minutes to see if that stops it happening again. Edit: It might in general be useful if the library checks the HTTP response status from all calls before trying to interpret the JSON payload, to give a more meaningful error to an application when something goes wrong. For me when this happens the HTTP response code is 509 and the response payload is:
but the Python API currently swallows this meaningful error information from Kia Connect and instead throws an error "string indices must be integers" because the JSON doesn't contain the expected data. |
I also encounter this error sometimes. Here is the stacktrace when called from my bluelink_monitor:
As you see, I use KiaUvoApiEU.py and hyundai_kia_connect_api-1.34.2. When I run it again immediately thereafter, it works. Indeed I would expect a try/catch error handling and maybe a retry mechanism?. Or is the idea that the calling program has to catch those type of errors and do a retry? At least I would expect a decent error message what the cause of the not filled data is? |
Ideally would love to add proper exceptions on this. Anyone able to drop a PR? This above error happens when the data is missing from the API. |
I have been running hyundai_kia_connect_monitor for a month (28 calls per day, ~840 calls per moonth) with a global try/catch/retry mechanism and the following exceptions have been reported: 30 times:
39 times:
6 time:
2 times:
|
@ZuinigeRijder very cool to see this in use! If you get time to work on error handling in this any contributions are appreciated. I somewhat keep the lights on around here but don't have the time to learn how to do this properly. Later this winter I may though. |
I just have a try/catch/retry around the calls:
You could also have this inside the main calls, e.g. check_and_refresh_token() and check_and_force_update_vehicles(600). Not as elegant as by checking contents, but this will at least avoid callers to work around the issue. |
I don't think retries will fit all use cases. For example in my case it ties up a thread in home assistant. The calling method wants to know when an update fails and will schedule a future retry when it can. Ideally I want to address as many API oddities as we can but I am not sure if failing API is one we can mask without impacting others. |
I agree with that. Already a very good improvement is that now in the Exception most situations are reported, which are valid exceptions. Since 15 December I got the following Exceptions (I did not add the count):
The following geocode error looks like this is not matched to a correct Exception, but I do not know if it is already solved:
But I think the best is to close this general issue, because the approach of throwing the correct Exception message is what should be done and is in most cases already done and specific issues should be created for a specific Exceptions which do not match the expected Exceptions, like the last one above. |
Getting "string indices must be integers" error on Check_and_refresh_token.
Started happening today. Seems like they did some kind of update for Kia app yesterday, as the app was down for a couple of hours.
The text was updated successfully, but these errors were encountered: