Skip to content

Raise InvalidServerVersion when Server is too old too#772

Merged
agners merged 3 commits intomainfrom
check-invalid-server-version
Jun 25, 2024
Merged

Raise InvalidServerVersion when Server is too old too#772
agners merged 3 commits intomainfrom
check-invalid-server-version

Conversation

@agners
Copy link
Copy Markdown
Collaborator

@agners agners commented 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.

@agners agners requested a review from MartinHjelmare June 25, 2024 07:45
@agners
Copy link
Copy Markdown
Collaborator Author

agners commented Jun 25, 2024

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.

@agners agners added the maintenance Code (quality) improvement or small enhancement which not a new feature label Jun 25, 2024
Comment thread matter_server/client/connection.py Outdated
Comment thread matter_server/client/connection.py Outdated
Comment thread matter_server/client/connection.py Outdated
agners added 3 commits June 25, 2024 13:02
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.
Copy link
Copy Markdown
Contributor

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@agners agners merged commit 8cb16f2 into main Jun 25, 2024
@agners agners deleted the check-invalid-server-version branch June 25, 2024 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Code (quality) improvement or small enhancement which not a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants