fix(workitems): Clear AssigneeIDs and CRMContactIDs when passed an empty slice to UpdateWorkItem

Summary

UpdateWorkItem did not clear AssigneeIDs or CRMContactIDs when passed an empty non-nil slice ([]int64{}), even though the field doc comments state that an empty slice clears the list. The empty slice was silently dropped and the mutation left the existing values in place. Passing an empty non-nil slice now sends an explicitly empty list and clears AssigneeIDs and CRMContactIDs. Fixes #2281 (closed)

What Changed

  • Changed the two guards in UpdateWorkItemOptions.wrap from len(opt.AssigneeIDs) > 0 and len(opt.CRMContactIDs) > 0 to opt.AssigneeIDs != nil and opt.CRMContactIDs != nil, so an empty non-nil slice now produces a widget in the mutation input instead of being skipped.
  • Removed omitempty from the AssigneeIDs and CRMContactIDs JSON tags, so an explicitly empty list is serialized as [] rather than dropped from the payload.

The issue mentions potentially replacing AssigneeIDs and CRMContactIDs from []int64 to *[]int64 but I did not see a good reason for this since it introduces a breaking change and Go slices already give us the nil state we need.

Testing

Added TestUpdateWorkItem_EmptySlicesClearAssigneesAndCRMContacts: calls UpdateWorkItem with empty non-nil AssigneeIDs and CRMContactIDs, and asserts the outgoing mutation sends AssigneeIDs and CRMContactIDs as empty arrays.

Merge request reports

Loading