Bug 54668 - [UCS] Date validation error is misleading
[UCS] Date validation error is misleading
Status: RESOLVED MOVED
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
https://git.knut.univention.de/univen...
:
Depends on:
Blocks: 54812 54973
  Show dependency treegraph
 
Reported: 2022-04-13 13:53 CEST by Jan-Luca Kiok
Modified: 2022-07-13 22:19 CEST (History)
7 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 3: Simply Wrong: The implementation doesn't match the docu
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain: 0.069
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Error handling
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan-Luca Kiok univentionstaff 2022-04-13 13:53:06 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'}
Comment 1 Florian Best univentionstaff 2022-04-13 14:39:04 CEST
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'
Comment 2 Jan-Luca Kiok univentionstaff 2022-04-13 15:07:57 CEST
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.
Comment 3 Carlos García-Mauriño univentionstaff 2022-04-21 13:16:49 CEST
Created issue in Gitlab https://git.knut.univention.de/univention/ucsschool/-/issues/691
Comment 4 Carlos García-Mauriño univentionstaff 2022-04-23 07:49:09 CEST
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).
Comment 5 Carlos García-Mauriño univentionstaff 2022-04-25 09:41:46 CEST
Docker image built and pushed: `docker-upload.software-univention.de/ucsschool-kelvin-rest-api 1.5.4 b9113212ebef 613MB`.
Comment 6 Daniel Tröder univentionstaff 2022-04-27 16:48:16 CEST
Why was a Kelvin Docker image build for this? The changes are in UCS!?
Comment 10 Carlos García-Mauriño univentionstaff 2022-04-29 17:22:49 CEST
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.
Comment 11 Daniel Tröder univentionstaff 2022-05-27 13:33:58 CEST
* 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.
Comment 15 Peter Stoll univentionstaff 2022-06-01 11:48:51 CEST
@Daniel would have also been our proposal to clone the bug. I will take care of the UCS part.
Comment 16 Carlos García-Mauriño univentionstaff 2022-06-02 05:54:55 CEST
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.
Comment 17 Carlos García-Mauriño univentionstaff 2022-06-02 06:11:13 CEST
MR for reverting the changes: https://git.knut.univention.de/univention/ucs/-/merge_requests/409
Comment 18 Carlos García-Mauriño univentionstaff 2022-06-02 15:05:24 CEST
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).
Comment 19 Peter Stoll univentionstaff 2022-06-02 16:03:31 CEST
Verified reverted code
YAML OK
Packet OK
Tested English and German error messages
Comment 21 Tobias Wenzel univentionstaff 2022-06-25 15:19:16 CEST
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.