Page MenuHomePhabricator

Internal Server Error when viewing list of projects
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

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
message
Multiple entries with same key: test/🤖=com.google.gerrit.extensions.common.ProjectInfo@546cbab9 and test/🤖=com.google.gerrit.extensions.common.ProjectInfo@545c835c
trace
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)

Event Timeline

The test/🤖 repository was created to check whether Gerrit properly supported Unicode in a repository name. The sole change sent to it was against a branch named 👾. Looks like Gerrit does not entirely support unicode :)

There is only one such repository on disk under the test/ namespace:

$ find /srv/gerrit/git/test -name '*.git'
/srv/gerrit/git/test/🤖.git
/srv/gerrit/git/test/gerrit-ping.git
/srv/gerrit/git/test/test.git

My guess it is a bug in the Guava library (com.google.common.collect.ImmutableMap) which get confused by the unicode character being used as map keys.

Mentioned in SAL (#wikimedia-releng) [2023-12-23T09:55:04Z] <hashar> gerrit: deleted repository test/🤖 | T353977

hashar claimed this task.