Fix CustomFields callback crashing during work item type change
What does this MR do?
CustomFields callback crashes when converting w... (#599287 - closed)
`/convert_to_ticket` and `/promote_to_incident`... (#594250 - closed)
Fixes a crash in WorkItems::Callbacks::CustomFields#after_save that occurs
when a work item's type is changed to a type that does not include the
custom_fields widget (e.g. converting an issue to a Service Desk ticket via
the /convert_to_ticket quick action, or using /type to change to a type
without custom fields support).
Root cause: When WorkItems::UpdateService processes a type change,
WidgetableService#initialize_callbacks! iterates all widgets on the current
work item. For any widget not supported by the new type, it stamps
excluded_in_new_type: true onto the callback params. This activates the
callback but leaves params as { excluded_in_new_type: true } — a Hash,
not the Array of field hashes that CustomFields#after_save expects. The
call to params.pluck(:custom_field_id) then raises:
Internal server error: no implicit conversion of Symbol into IntegerFix: Add the excluded_in_new_type? early return that every other
callback (weight, iteration, health_status, color, status, etc.) already has.
One line added, consistent with the established pattern.
Steps to validate locally
Scenario 1 — /convert_to_ticket quick action (main trigger):
- Set up your instance to activate incoming email and Service Desk (use
gitlab.ymlportion of the snippet) - Open an issue
- Add a comment with
/convert_to_ticket user@example.com - Save
Before this fix: GraphQL returns Internal server error: no implicit conversion of Symbol into Integer and the conversion fails.
After this fix: the issue is successfully converted to a Service Desk ticket.
Scenario 2 — /type quick action:
- Open an issue
- Use
/type Task(or any other type that also hascustom_fieldsin its widget list — this won't reproduce the crash; use a type without it) - To reproduce, target a type that does not include
custom_fields
Note: most system-defined types do include custom_fields, so ticket (via
/convert_to_ticket) is currently the clearest repro path.
Closes #599287 (closed)
Closes #594250 (closed)