Skip to content

Commit a5efa30

Browse files
committed
Catch ApolloHttpException when fetching vulnerabilities
We have experienced in production that the apollo client fails to fetch vulnerabilities, which results in the application becoming stagnant. In these cases, we simply want the application to continue, hoping that vulnerabilities will be fetched successfully on the next loop.
1 parent 2c333e6 commit a5efa30

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/main/kotlin/no/digipost/github/monitoring/GithubGraphql.kt

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import com.apollographql.apollo3.ApolloCall
44
import com.apollographql.apollo3.ApolloClient
55
import com.apollographql.apollo3.api.ApolloResponse
66
import com.apollographql.apollo3.api.Optional
7+
import com.apollographql.apollo3.exception.ApolloHttpException
78
import com.github.graphql.client.GetVulnerabilityAlertsForRepoQuery
89
import com.github.graphql.client.QueryRepositoriesQuery
910
import kotlinx.coroutines.channels.Channel
@@ -47,12 +48,16 @@ fun fetchAllReposWithVulnerabilities(apolloClient: ApolloClient, githubApiClient
4748
repositories.add(r)
4849

4950
launch {
50-
val vulnerabilities = getVulnerabilitiesForRepo(apolloClient, r.name)
51-
if (vulnerabilities.isNotEmpty()) {
52-
r.copy(vulnerabilities = vulnerabilities).let {
53-
logger.info("{} sårbarheter i {}", vulnerabilities.size, r.name)
54-
vulnRepositories[it.name] = vulnerabilities
51+
try {
52+
val vulnerabilities = getVulnerabilitiesForRepo(apolloClient, r.name)
53+
if (vulnerabilities.isNotEmpty()) {
54+
r.copy(vulnerabilities = vulnerabilities).let {
55+
logger.info("{} sårbarheter i {}", vulnerabilities.size, r.name)
56+
vulnRepositories[it.name] = vulnerabilities
57+
}
5558
}
59+
} catch (e: ApolloHttpException) {
60+
logger.warn("ApolloHttpException ved henting av sårbarheter for repo {}", r.name, e)
5661
}
5762
}
5863

0 commit comments

Comments
 (0)