-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Fix offline condition when one call fails #198
base: master
Are you sure you want to change the base?
Conversation
Just had a quick look, but this is breaking some things. But I dont see what this should fix, its just rewritten in bit different way. Offline condition when call fails is intended of course, that is how integration is supposed to act. |
I'm not sure of how this is true, I've made it so that any exception will set To be clear, the existing code will take everything not a 200 or 500 offline (exception or not), whereas this code will only take the integration offline when an exception is thrown, everything else just returns None and sets the error accordingly. This stops the integration from not working when the EDIT: I see that you are mapping the errors to translations so I may have broken that by using the exceptions directly, but I'm not sure that this needs translating TBH as the exceptions give you more information as to exactly what went wrong, but i'll push an update that mimics that behavior. |
You are setting no_response every time there on exception without trying to get status code. I had it written in such way because exception there arises for other reasons then no response error. |
The way i read your code, the only exceptions thrown in that block would be from the request (in which case there would no response) or from the json parsing (which would but the status code would be 200). The only case I can see here that this code now differs is if there is a parse exception on the json.
That's not quite accurate, the modified code still returns None if there are status codes other than 200 when there is no exception, and acts exactly like it did before for your handled cases other than not going offline on purpose. The point of the PR is to stop it from going offline when another status code is returned, so that one failed API call does not mean that everything is failed. I don't see this as acting as everything ok, just that the server is up but not returning data, which is what this method still returns and the outer dict is cleared, which should lead to no data available which seems correct. If there is some other opaque factor external then I'm not sure I understand it, so feel free to reject this PR as in that case, I feel that in that case the needed changes to handle partial API outages in a way to address your concerns are larger. |
Proposed change
This change redoes the API request logic to not get knocked offline for a bad response code, changing it to only go offline if an API causes an exception (like timeout or a request error, etc). Resolves #191.
Type of change
Additional information
I have been having the same issue as #191 so decided to rework the logic slightly, also fixed the lock handling to be a little cleaner.
Checklist