Fix Date::Error exception when viewing audit logs for an invalid date
What does this MR do and why?
- We already have the checks in place, however, we were not returning when the filter failed and therefore it raised an exception later on when we tried to parse the invalid date.
- Added an early return to the
validate_date_params
method to fix the exception raised when an invalid date is passed for eithercreated_before
orcreated_after
parameter. - Included the
before_action validate_date_params
toAuditLogReportsController
to prevent exceptions if invalid dates are passed for while downloading the audit events csv.
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Ensure that you have an ultimate license.
- View the instance audit logs with an invalid date. Example -
https://gdk.test:3000/admin/audit_logs?created_after=2019-02-01&created_before=2022-02-32
. An error "Invalid date format. Please use UTC format as YYYY-MM-DD" should be displayed. - View the group audit logs with an invalid date. Example -
https://gdk.test:3000/groups/flightjs/-/audit_events?created_before=2021-13-31
. The same error should be displayed. - View the project audit logs with an invalid date. Example -
https://gdk.test:3000/flightjs/Flight/-/audit_events?created_before=w
. The error should be displayed this time as well. - Try downloading the audit even CSV for an invalid date. Example -
https://gdk.test:3000/admin/audit_log_reports.csv?created_before=2022-02-30
. HTTP status 400 should be returned.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #352747 (closed)