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.wrapfromlen(opt.AssigneeIDs) > 0andlen(opt.CRMContactIDs) > 0toopt.AssigneeIDs != nilandopt.CRMContactIDs != nil, so an empty non-nil slice now produces a widget in the mutation input instead of being skipped. - Removed
omitemptyfrom theAssigneeIDsandCRMContactIDsJSON 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.