Skip to content

Scan for label-filtered ListProjectMergeRequests results in Bad Request

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

If filtering by labels in ListProjectMergeRequests requesting the second page results in a Bad Request from GitLab due to two labels fields sent on the request.

gitlabLabels := gitlab.LabelOptions([]string{"foobar"})

opts := &gitlab.ListProjectMergeRequestsOptions{
	Labels: &gitlabLabels,
}
seq, hasErr := gitlab.Scan(func(p gitlab.PaginationOptionFunc) ([]*gitlab.BasicMergeRequest, *gitlab.Response, error) {
	return client.MergeRequests.ListProjectMergeRequests("1337", opts, p)
})

The merge requests from the first page are properly iterated over, but when sending the request for the second page the GET parameters include both labels=foobar and label[]=foobar, the latter from the "next" link header from the first page and the former from our ListProjectMergeRequestsOptions.

The array form of the labels parameter does not seem to be documented (should I open an issue in the GitLab project?). Should Scan be handling this better?

Edited by 🤖 GitLab Bot 🤖
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information