More appropriate info when GitHub's API is down
The-Huginn opened this issue · 4 comments
Describe the bug
Recently, on 1st of March, '24, there was an outage of GitHub's API. However, it is propagated as a simple HttpException.
Expected behavior
It would be nice, to have a custom Exception for such edge case.
Additional context
I see, this is an edge case, that might not be caught often. However, it would be nice to have. The root cause for my problem came from GitHubConnectorResponserErrorHandler. I unfortunately do not have the status code. But I have the body of the returned response, please below
I am not sure, if you would agree with contains()
to search for some keywords from the response due to performance concerns. I would be glad to take a look at this issue, if you would like me to.
Full stacktrace with the returned message:
Exception: java.lang.IllegalStateException: Error downloading file .github/wildfly-bot.yml for repository wildfly/wildfly
at io.quarkiverse.githubapp.runtime.github.GitHubFileDownloader.getFileContent(GitHubFileDownloader.java:40)
at io.quarkiverse.githubapp.runtime.github.GitHubFileDownloader_ClientProxy.getFileContent(Unknown Source)
at io.quarkiverse.githubapp.runtime.github.GitHubConfigFileProviderImpl.fetchConfigFile(GitHubConfigFileProviderImpl.java:58)
at io.quarkiverse.githubapp.runtime.github.GitHubConfigFileProviderImpl.fetchConfigFile(GitHubConfigFileProviderImpl.java:48)
at io.quarkiverse.githubapp.runtime.github.GitHubConfigFileProviderImpl_ClientProxy.fetchConfigFile(Unknown Source)
at io.quarkiverse.githubapp.runtime.RequestScopeCachingGitHubConfigFileProvider.lambda$getConfigObject$0(RequestScopeCachingGitHubConfigFileProvider.java:36)
at java.base@21.0.2/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at io.quarkiverse.githubapp.runtime.RequestScopeCachingGitHubConfigFileProvider.getConfigObject(RequestScopeCachingGitHubConfigFileProvider.java:35)
at io.quarkiverse.githubapp.runtime.RequestScopeCachingGitHubConfigFileProvider_ClientProxy.getConfigObject(Unknown Source)
at io.xstefank.wildfly.bot.PullRequestFormatProcessor_Multiplexer.pullRequestFormatCheck_f55c171fc8729e6d1c598a894a7ad6b204f6ef0e(Unknown Source)
at io.xstefank.wildfly.bot.PullRequestFormatProcessor_Multiplexer_Observer_pullRequestFormatCheck_f55c171fc8729e6d1c598a894a7ad6b204f6ef0e_JOC2kNIt5GQfSNelJKaaWpTCmEA.notify(Unknown Source)
at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:346)
at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:328)
at io.quarkus.arc.impl.EventImpl$1.get(EventImpl.java:112)
at java.base@21.0.2/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:582)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base@21.0.2/java.lang.Thread.runWith(Thread.java:1596)
at java.base@21.0.2/java.lang.Thread.run(Thread.java:1583)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:833)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:211)
Caused by: org.kohsuke.github.HttpException: <!DOCTYPE html>
<!--
Hello future GitHubber! I bet you're here to remove those nasty inline styles,
DRY up these templates and make 'em nice and re-usable, right?
Please, don't. https://github.com/styleguide/templates/2.0
-->
<html>
<head>
<title>Unicorn! · GitHub</title>
<style type="text/css" media="screen">
body {
background-color: #f1f1f1;
margin: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.container { margin: 50px auto 40px auto; width: 600px; text-align: center; }
a { color: #4183c4; text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { letter-spacing: -1px; line-height: 60px; font-size: 60px; font-weight: 100; margin: 0px; text-shadow: 0 1px 0 #fff; }
p { color: rgba(0, 0, 0, 0.5); margin: 10px 0 10px; font-size: 18px; font-weight: 200; line-height: 1.6em;}
ul { list-style: none; margin: 25px 0; padding: 0; }
li { display: table-cell; font-weight: bold; width: 1%; }
.logo { display: inline-block; margin-top: 35px; }
.logo-img-2x { display: none; }
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
}
#suggestions {
margin-top: 35px;
color: #ccc;
}
#suggestions a {
color: #666666;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
}
</style>
</head>
<body>
<div class="container">
<p>
<img width="200" src="data:image/png;base64,...omitted...">
</p>
<p><strong>We had issues producing the response to your request.</strong></p>
<p>Sorry about that. Please try refreshing and contact us if the problem persists.</p>
<div id="suggestions">
<a href="https://github.com/contact">Contact Support</a> —
<a href="https://www.githubstatus.com">GitHub Status</a> —
<a href="https://twitter.com/githubstatus">@githubstatus</a>
</div>
<a href="/" class="logo logo-img-1x">
<img width="32" height="32" title="" alt="" src="data:image/png;base64,...omitted..." />
</a>
<a href="/" class="logo logo-img-2x">
<img width="32" height="32" title="" alt="" src="data:image/png;base64,...omitted..." />
</a>
</div>
</body>
</html>
at org.kohsuke.github.GitHubConnectorResponseErrorHandler$1.onError(GitHubConnectorResponseErrorHandler.java:62)
at org.kohsuke.github.GitHubClient.detectKnownErrors(GitHubClient.java:473)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:434)
at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:403)
at org.kohsuke.github.Requester.fetch(Requester.java:85)
at org.kohsuke.github.GHRepository.getFileContent(GHRepository.java:2680)
at io.quarkiverse.githubapp.runtime.github.GitHubFileDownloader.getFileContent(GitHubFileDownloader.java:27)
... 24 more
We are talking about an exception/error case, so performance is less of a concern. We could also limit the performance implications by checking .startsWith("<!DOCTYPE html>\n<--")
and some other inexpensive checks.
I'd suggest adding a new ServiceDownExceptuon
that inherits from http exception. That way existing code will still be able to handle it as a standard http error.
Maybe we could test the content type is text/html
and we have a line starting with <title>Unicorn!
. The Unicorn has been the sign of a non-working GitHub for ages.
Sounds good, I will try to come back with a solution early next week hopefully.
Note, You will need to create custom test input files to verify the functionality.