Resolve "Unassign all assignees from merge request via Rest API not possible"
What does this MR do?
Addresses #330369 (closed)
Our documentation states clearly:
parameter | type | required | explanation |
---|---|---|---|
assignee_id |
integer |
no | The ID of the user to assign the merge request to. Set to 0 or provide an empty value to unassign all assignees. |
assignee_ids |
integer array |
no | The ID of the user(s) to assign the MR to. Set to 0 or provide an empty value to unassign all assignees. |
A recent change broke this contract in respect of the special 0
sentinel value.
(technically there is no 'special 0 sentinel value' - but instead this treatment of 0 is a hack to get around the fact
that it is difficult to express an empty array or null in URL encoded query parameters - the previous code simply filtered
out all unrecognized users and thus treated [0] === []
. This behaviour is all kinds of dangerous and weird, so I am
reluctant to allow it in general, but it is ok - for now at least - to allow this behavior for 0
alone, since 0
is not a valid User ID).
This MR adds special handling that treats 0
assignee IDs as if they had not been provided, ensuring that we get the correct behavior (clearing assignees). Under this change, the assignee lists []
, [0]
, [0, 0, 0]
are equivalent.
Alternatives:
We could have treated [0]
as a special case, distinct from [123, 0]
and so forth. However, the previous implementation just ignored all non-existing user IDs. This change brings those semantics back, but only for 0
.
We could also change the documentation, and redefine how we accept empty lists. That is not acceptable, given the presence of existing code that uses the current interface.
Does this MR meet the acceptance criteria?
Conformity
-
I have included a changelog entry, or it's not needed. (Does this MR need a changelog?) -
I have added/updated documentation, or it's not needed. (Is documentation required?) -
I have properly separated EE content from FOSS, or this MR is FOSS only. (Where should EE code go?) -
I have added information for database reviewers in the MR description, or it's not needed. (Does this MR have database related changes?) -
I have self-reviewed this MR per code review guidelines. -
This MR does not harm performance, or I have asked a reviewer to help assess the performance impact. (Merge request performance guidelines) -
I have followed the style guides.
Availability and Testing
-
I have added/updated tests following the Testing Guide, or it's not needed. (Consider all test levels. See the Test Planning Process.) -
I have tested this MR in all supported browsers, or it's not needed. -
I have informed the Infrastructure department of a default or new setting change per definition of done, or it's not needed.
Related to #330369 (closed)