Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle cases where an administrator doesn't allow private repos to be forked #150

Open
justinharringa opened this issue May 18, 2020 · 1 comment

Comments

@justinharringa
Copy link
Contributor

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
@rahulsurwade08
Copy link
Contributor

I would love to contribute for this issue. How can I get started?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants