Skip to content

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.

Screenshot_2025-10-23_at_2.06.18_pm

The issue occurs because:

  1. status_with_fallback builds a non-persisted CurrentStatus record with the default status.
  2. When status is called on this non-persisted record, it calls find_mapped_status.
  3. find_mapped_status calls mapping.applicable_for?(updated_at) where updated_at is nil.
  4. This causes the ArgumentError when comparing nil with TimeWithZone (Error in Sentry).

Steps to reproduce

  1. Create a new group, project, and two issues.
  2. Delete the current status record from the last issue via the Rails console: WorkItem.last.current_status.delete.
  3. In the issues settings page (/groups/group-name/-/settings/issues), create a new status called New default.
  4. Delete the existing To do status, map it to New default, and set New default as the default open status.
  5. Re-add the To do status and make it the default again.
  6. Navigate to the group or project work items list.
  7. Before the fix: Expect to see the 'Something went wrong' error when fetching work items.
  8. 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