Raise InvalidServerVersion when Server is too old too#772
Merged
Conversation
Collaborator
Author
|
This is an alternative to the suggested change in Core home-assistant/core#118858. Compared to the change in Core, it makes the connection to really fail. So this will force people to upgrade the add-on on schema bump. |
20 tasks
MartinHjelmare
requested changes
Jun 25, 2024
Currently InvalidServerVersion was only raised when the client was too old (Server wasn't able to handle such an old client anymore), e.g. after a backwards incompatible change Server side. However, if the client was newer than the Server schema version, no error was raised. This essentially never triggered the add-on update logic in Core. This change makes sure that we raise InvalidServerVersion when the Server is too old for the client too. We also add properties to the Exception so a client can figure out which situation we are dealing with (too old/too new) and act accordingly.
Instead of adding properties to the exceptions and determine the cause of the version mismatch on the handler side again, just use separate exceptions for the different cases.
a2b4022 to
287d48b
Compare
20 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently InvalidServerVersion was only raised when the client was too old (Server wasn't able to handle such an old client anymore), e.g. after a backwards incompatible change Server side.
However, if the client was newer than the Server schema version, no error was raised. This essentially never triggered the add-on update logic in Core.
This change makes sure that we raise InvalidServerVersion when the Server is too old for the client too. We also add properties to the Exception so a client can figure out which situation we are dealing with (too old/too new) and act accordingly.