Steps to replicate the issue (include links if applicable):
- Go to https://gerrit.wikimedia.org/r/admin/repos,2600 (this corresponds to Page 105, as each page lists 25 projects)
- Click the next page button (right arrow at bottom of page) to go to Page 106
- Note: The above steps may no longer work if projects are added or deleted after the filing of this bug report. If that is the case, just go to https://gerrit.wikimedia.org/r/admin/repos and keep clicking the next page button.
What happens?: The following error message appears:
An error occurred
Error 500 (Server Error): Internal server error
Endpoint: /projects/?*
What should have happened instead?: A list of between 1 and 25 different projects should have appeared.
Software version (skip for WMF-hosted wikis like Wikipedia): Gerrit 3.5.6 as of the filing of this bug report
Other information (browser name/version, screenshots, etc.):
I started getting these errors sometime within the last month or so. I was using the API endpoint mentioned in the error message (which is documented in the Gerrit manual) to retrieve the list of projects from within a script. The SSH command gerrit ls-projects still works if the output format is left at the default of TEXT (rather than JSON), though it lists the project "test/🤖" three times.
By changing the Skip (S) and Limit (n) values in the API request, I could observe that the error only occurs when the "test/🤖" project would have appeared in the same JSON response more than once, likely because it is being used as a key within the object.
SSH gerrit ls-projects -S 2640 --format JSON
Multiple entries with same key: test/🤖=com.google.gerrit.extensions.common.ProjectInfo@546cbab9 and test/🤖=com.google.gerrit.extensions.common.ProjectInfo@545c835c
java.lang.IllegalArgumentException: Multiple entries with same key: test/🤖=com.google.gerrit.extensions.common.ProjectInfo@546cbab9 and test/🤖=com.google.gerrit.extensions.common.ProjectInfo@545c835c at com.google.common.collect.ImmutableMap.conflictException(ImmutableMap.java:211) at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:205) at com.google.common.collect.ImmutableSortedMap.fromEntries(ImmutableSortedMap.java:387) at com.google.common.collect.ImmutableSortedMap.access$100(ImmutableSortedMap.java:61) at com.google.common.collect.ImmutableSortedMap$Builder.build(ImmutableSortedMap.java:549) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:582) at com.google.gerrit.server.restapi.project.ListProjects.applyAsQuery(ListProjects.java:364) at com.google.gerrit.server.restapi.project.ListProjects.printQueryResults(ListProjects.java:382) at com.google.gerrit.server.restapi.project.ListProjects.displayToStream(ListProjects.java:412) at com.google.gerrit.sshd.commands.ListProjectsCommand.run(ListProjectsCommand.java:45) at com.google.gerrit.sshd.SshCommand.lambda$start$1(SshCommand.java:81) at com.google.gerrit.sshd.BaseCommand$TaskThunk.run(BaseCommand.java:495) at com.google.gerrit.server.logging.LoggingContextAwareRunnable.run(LoggingContextAwareRunnable.java:113) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:612) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)