Fix returning default statuses when the mapping is present
Problem
Bug report: https://gitlab.com/gitlab-com/request-for-help/-/issues/3609.
When a work item doesn't have a current status record (all work items created before the MVC1 release of configurable statuses in %18.2), they fall back to lifecycle's default status through a non-persisted CurrentStatus
record using the status_with_fallback method.
This caused ArgumentError when find_mapped_status tried to compare nil
updated_at
with mapping's valid_until
timestamp.
The issue occurs because:
-
status_with_fallback
builds a non-persistedCurrentStatus
record with the default status. - When
status
is called on this non-persisted record, it callsfind_mapped_status
. -
find_mapped_status
callsmapping.applicable_for?(updated_at)
whereupdated_at
isnil
. - This causes the
ArgumentError
when comparingnil
withTimeWithZone
(Error in Sentry).
Steps to reproduce
- Create a new group, project, and two issues.
- Delete the current status record from the last issue via the Rails console:
WorkItem.last.current_status.delete
. - In the issues settings page (
/groups/group-name/-/settings/issues
), create a new status calledNew default
. - Delete the existing
To do
status, map it toNew default
, and setNew default
as the default open status. - Re-add the
To do
status and make it the default again. - Navigate to the group or project work items list.
- Before the fix: Expect to see the 'Something went wrong' error when fetching work items.
- After the fix: The work item list and drawer should load without issues.
Notes
- The issue started occurring in %18.6, after the deployment of !208414 (merged).
- This bug only affects the feature in %18.6, so no backports are required.
Edited by Agnes Slota