Making the following query to the git.sr.ht API:
query repositoriesByUser {
user(username: "sircmpwn") {
repositories {
results {
name
}
}
}
}
results in the "hare" repository being returned 4 times and the "harec" repository 3 times.
If my understanding is correct, this particular query will be handled by the following function: https://git.sr.ht/~sircmpwn/git.sr.ht/tree/master/item/api/graph/schema.resolvers.go#L1271
I have tried to investigate under what circumstances results would be duplicated, but have not managed to figure it out. I have also not managed to replicate the issue on my local instance.
The only lead I can see is that there might be a problematic join with the "access" table, especially since both of the aforementioned repositories were previously unlisted and later became public. This is, however, just a guess, and might be wrong.
I was able to replicate the issue on the https://git.sr.ht instance. To reproduce, create a public repository and grant two or more users access to it (access type does not matter). The issue is with the join, indeed, as the result rows will be duplicated for each access entry, and all of them will be returned because
repo.visibility = 'PUBLIC'
is true and the condition short-circuits.