Fix misleading error on project import quota violation Previously, when a project import failed during the GitCloneStep, the error handling logic assumed that all `ResourceConflictException`s indicated the repository already existed. This led to incorrect error messages being shown to users, even when the actual cause was unrelated. This patch removes the special handling for `ResourceConflictException` and instead exposes the full underlying message from the `RestApiException`. As a result, users now receive accurate feedback, for example, when import fails due to exceeding the `maxProjects` quota in a namespace. Improves user experience by providing correct diagnostics for import failures, aiding in quicker debugging and resolution. Bug: Issue 445765274 Change-Id: I7ab32c23140288b3c259d4b8e5fcb3135f14ce7c
diff --git a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java index 9d09f51..d2b589f 100644 --- a/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java +++ b/github-plugin/src/main/java/com/googlesource/gerrit/plugins/github/git/GitCloneStep.java
@@ -21,7 +21,6 @@ import com.google.gerrit.extensions.api.projects.ProjectInput; import com.google.gerrit.extensions.events.ProjectDeletedListener; import com.google.gerrit.extensions.registration.DynamicSet; -import com.google.gerrit.extensions.restapi.ResourceConflictException; import com.google.gerrit.extensions.restapi.RestApiException; import com.google.gerrit.server.IdentifiedUser; import com.google.gerrit.server.account.AccountState; @@ -114,10 +113,9 @@ pi.parent = config.getBaseProject(ghRepository.isPrivate()); pi.branches = Stream.ofNullable(ghRepository.getDefaultBranch()).collect(toList()); gerritApi.projects().create(pi).get(); - } catch (ResourceConflictException e) { - throw new GitDestinationAlreadyExistsException(projectName); } catch (RestApiException e) { - throw new GitException("Unable to create repository " + projectName, e); + throw new GitException( + "Unable to create repository " + projectName + ":" + e.getMessage(), e); } }