dockerfile-image-update
dockerfile-image-update copied to clipboard
Gracefully handle cases where an administrator doesn't allow private repos to be forked
We currently fail with a stacktrace when we attempt to fork a private repo where the administrator has disallowed that. While we don't fall down, it would be nice to present a better error message without a full stacktrace.
Sample redacted error:
org.kohsuke.github.HttpException: {"message":"The repository exists, but forking is disabled.","documentation_url":"https://developer.github.com/enterprise/2.19/v3/repos/forks/#create-a-fork"}
at org.kohsuke.github.GitHubClient.interpretApiError(GitHubClient.java:440)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:368)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:312)
at org.kohsuke.github.Requester.send(Requester.java:56)
at org.kohsuke.github.GHRepository.fork(GHRepository.java:1244)
at com.salesforce.dockerfileimageupdate.utils.GitHubUtil.createFork(GitHubUtil.java:71)
at com.salesforce.dockerfileimageupdate.utils.DockerfileGitHubUtil.getOrCreateFork(DockerfileGitHubUtil.java:55)
at com.salesforce.dockerfileimageupdate.subcommands.impl.Parent.forkRepositoriesFoundAndGetPathToDockerfiles(Parent.java:181)
at com.salesforce.dockerfileimageupdate.subcommands.impl.Parent.execute(Parent.java:84)
at com.salesforce.dockerfileimageupdate.CommandLine.main(CommandLine.java:52)
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://somegithubenterprise.com/api/v3/repos/someorg/somerepo/forks
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1944)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1939)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1938)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1508)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
at org.kohsuke.github.GitHubHttpUrlConnectionClient$HttpURLConnectionResponseInfo.bodyStream(GitHubHttpUrlConnectionClient.java:197)
at org.kohsuke.github.GitHubResponse$ResponseInfo.getBodyAsString(GitHubResponse.java:313)
at org.kohsuke.github.Requester.lambda$send$0(Requester.java:56)
at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:406)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:360)
... 8 more
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: https://somegithubenterprise.com/api/v3/repos/someorg/somerepo/forks
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:347)
at org.kohsuke.github.GitHubHttpUrlConnectionClient.getResponseInfo(GitHubHttpUrlConnectionClient.java:69)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:348)
... 8 more
I would love to contribute for this issue. How can I get started?