Skip to content

Commit 7e401fb

Browse files
authored
Fix repo API listing stability (#12057)
Repo listings are paginated in the API now. Unfortunately, they are ORDER BY updated_unix which only has second resolution. This means that if you do a listing when multiple projects were created at the same time you can unstable ordering. If that unstable ordering happens at a page boundary you may fail to get a complete repo listing. To make things worse sorting by updated_unix means that we may never get a complete listing because udpated_unix can change independent of our API calls. Fix this by making the API repo listing order by id instead.
1 parent 482ba93 commit 7e401fb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

routers/api/v1/user/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func listUserRepos(ctx *context.APIContext, u *models.User, private bool) {
2222
Actor: u,
2323
Private: private,
2424
ListOptions: opts,
25+
OrderBy: "id ASC",
2526
})
2627
if err != nil {
2728
ctx.Error(http.StatusInternalServerError, "GetUserRepositories", err)

0 commit comments

Comments
 (0)