Skip to content

fix: use pagination to list MR discussions#529

Merged
harrisoncramer merged 2 commits intoharrisoncramer:developfrom
jakubbortlik:fix/use-pagination-to-list-discussions
Mar 18, 2026
Merged

fix: use pagination to list MR discussions#529
harrisoncramer merged 2 commits intoharrisoncramer:developfrom
jakubbortlik:fix/use-pagination-to-list-discussions

Conversation

@jakubbortlik
Copy link
Copy Markdown
Collaborator

Closes #182.

This uses the gitlab.Scan function to iterate over all discussions and handle errors after the iterator is exhausted. The test for non-200s is no longer needed as the Scan function transforms such responses to standard errors.

This PR also limits the number of API calls for emojis by only fetching emojis for the filtered discussions.

I've tested both fixes in a large MR and it correctly fetched all discussions (that were otherwise not fetched without the pagination) and emojis.

This uses the gitlab.Scan function to iterate over all discussions and
handle errors after the iterator is exhausted. The test for non-200s is
no longer needed as the Scan function transforms such responses to
standard errors.
Comment on lines -130 to -140
t.Run("Handles non-200s from Gitlab client", func(t *testing.T) {
request := makeRequest(t, http.MethodPost, "/mr/discussions/list", DiscussionsRequest{Blacklist: []string{}})
svc := middleware(
discussionsListerService{testProjectData, fakeDiscussionsLister{testBase: testBase{status: http.StatusSeeOther}}},
withMr(testProjectData, fakeMergeRequestLister{}),
withPayloadValidation(methodToPayload{http.MethodPost: newPayload[DiscussionsRequest]}),
withMethodCheck(http.MethodPost),
)
data, _ := getFailData(t, svc, request)
checkNon200(t, data, "Could not list discussions", "/mr/discussions/list")
})
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitlab.Scan handles errors differently, i.e., it doesn't set a non-200 status code on the response, so this test is no longer valid.

@harrisoncramer harrisoncramer merged commit 68fabb5 into harrisoncramer:develop Mar 18, 2026
2 checks passed
@jakubbortlik jakubbortlik deleted the fix/use-pagination-to-list-discussions branch March 18, 2026 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

discussions tree does not contain all discussions

2 participants