Skip to content

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

Availability and Testing

Related to #330369 (closed)

Edited by Alex Kalderimis

Merge request reports