Univention Bugzilla – Bug 56399
Pydantic update breaks class ListenerFileAttributeError
Last modified: 2023-08-21 12:20:34 CEST
+++ This bug was initially created as a clone of Bug #56265 +++ +++ This bug was initially created as a clone of Bug #56097 +++ With Bug #56265 and commit https://git.knut.univention.de/univention/components/ucsschool-id-connector/-/commit/f585e9b06b9b314de65b1a96fbaa51aacdbb4ca5 `pydantic` was updated: ``` -pydantic[ujson,email]==0.32.2 +pydantic[ujson,email]>=1.10.9,<1.11.0 ``` The `PydanticErrorMixin` class changed with the following commit, which happened somewhere between 0.32.2 and 1.10.9: https://github.com/pydantic/pydantic/commit/24ac05276bdb9d97b57e65ab37672a38bfbde711#diff-a9fb7aabd1a5225682c2fe6ecaee290b3376ccb37543d854851b5be607ba9d06L8-L18 The `__dict__` attribute of instances of `PydanticErrorMixin` are now overwritten by the `__init__` method with keyword argument dictionary. The `ListenerFileAttributeError` inherits from `PydanticValueError` which in turn inherits from `PydanticErrorMixin`. The update broke the initialization of `ListenerFileAttributeError`, `msg_template` and `code` are no longer set, and it then falls back to the class attributes. This results in confusing and wrong error output. In `ListenerFileAttributeError` we now no longer need to set the attributes `code` and `msg_template` attributes and can rely on the super class from pydantic to do that for us. This should fix the bug: ``` diff --git a/src/ucsschool_id_connector/models.py b/src/ucsschool_id_connector/models.py index 7269b8d..e210976 100644 --- a/src/ucsschool_id_connector/models.py +++ b/src/ucsschool_id_connector/models.py @@ -50,17 +50,6 @@ class ListenerFileAttributeError(PydanticValueError): code = "invalid_listener_file" msg_template = 'Missing or empty value in listener file: "{key}"="{value}"' - def __init__(self, *args, **kwargs): - try: - self.code = kwargs.pop("code") - except KeyError: - pass - try: - self.msg_template = kwargs.pop("msg_template") - except KeyError: - pass - super().__init__(*args, **kwargs) - class MissingArgumentError(PydanticValueError): code = "missing_argument" ```
An issue in a customer environment was, that the msg_template and code attributes were overwritten by the super().__init__() call. A plugin working with those values stopped working. No new users could be provisioned.
Updates for UCS@school ID Connector 2.2.8 have been released. https://docs.software-univention.de/ucsschool-id-connector/HISTORY.html If this error occurs again, please clone this bug.