Univention Bugzilla – Bug 54668
[UCS] Date validation error is misleading
Last modified: 2022-07-13 22:19:43 CEST
Upon creating a school user with an expiration date later than 31.12.2099 the error "Not a valid Date" is thrown, but the date format is indeed right (maybe our syntax expects something 20**?). For reference: Unprocessable Entity: {'userexpiry': 'The property userexpiry has an invalid value: Invalid syntax. Account expiry date: Not a valid Date'}
The userexpiry property uses the "date2" syntax class which expects '1961-01-01' or '21.12.03'. >>> univention.admin.syntax.date2.parse('31.12.99') '1999-12-31' >>> univention.admin.syntax.date2.parse('31.12.2099') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/fbest/git2/ucs/management/univention-directory-manager-modules/modules/univention/admin/syntax.py", line 2335, in parse raise univention.admin.uexceptions.valueError(_("Not a valid Date")) univention.admin.uexceptions.valueError: Not a valid Date >>> univention.admin.syntax.date2.parse('2099-12-31') '2099-12-31'
For clarity: The error is thrown when creating a user with "userexpiry" : "3000-01-01", whereas "2099-01-01" does work. Kelvin says that "expiration_date: date of password expiration (optional, format: YYYY-MM-DD)" so the error is misleading: The format is correct, but the range seems to be violated.
Created issue in Gitlab https://git.knut.univention.de/univention/ucsschool/-/issues/691
MR merged (https://git.knut.univention.de/univention/ucs/-/merge_requests/336), package built (`15.0.11-46A~5.0.0.202204230745`) and advisory updated (https://git.knut.univention.de/univention/ucs/-/commit/fc9046f66142886c5b90746c0e70fa5e9e34ee48).
Docker image built and pushed: `docker-upload.software-univention.de/ucsschool-kelvin-rest-api 1.5.4 b9113212ebef 613MB`.
Why was a Kelvin Docker image build for this? The changes are in UCS!?
What happened is that I used the same Bugzilla bug for both UCS and UCS@School. sorry for that. The UCS@School part is in https://git.knut.univention.de/univention/ucsschool/-/issues/691 which was solved with https://git.knut.univention.de/univention/ucsschool/-/merge_requests/94 It consisted in specifying the valid date ranges in the documentation comments that are shown in the Swagger UI. The UCS part is fixed in https://git.knut.univention.de/univention/ucs/-/merge_requests/336 The changes consisted in specifying the valid date range in the exception message.
* Please fix the syntax class for "expiration_date" in ucsschool.lib.models.attributes.UserExpirationDate. It should be the same as it is defined in UDM (management/univention-directory-manager-modules/modules/univention/admin/handlers/users/user.py → "userexpiry"): "date2". -> fix this in 4.4, 5.0 and kelvin. * The syntax class for "birthday" is "iso8601Date". That has no limit on the time range. Please revert that in Kelvins OpenAPI definition.
@Daniel would have also been our proposal to clone the bug. I will take care of the UCS part.
As suggested by Peter Stoll I will revert the changes. The new error message does not cover all requirements for a valid date. It includes valid value ranges but does not explain all possible formats for the Germand date format and thus is more inaccurate than the old “Invalid Date” error.
MR for reverting the changes: https://git.knut.univention.de/univention/ucs/-/merge_requests/409
MR merged (https://git.knut.univention.de/univention/ucs/-/merge_requests/409), package built (`univention-directory-manager-modules`: `15.0.11-51A~5.0.0.202206021502`) and advisory updated (https://git.knut.univention.de/univention/ucs/-/commit/126042c9f69d7986aadfce461160a9ec1758b95c).
Verified reverted code YAML OK Packet OK Tested English and German error messages
I provided a suggestion with the valid date formats in the new MR here https://git.knut.univention.de/univention/ucs/-/merge_requests/430 To shorten the qa process, please feel free to contact me directly.