Skip to content

Commit fc617ac

Browse files
authored
Merge pull request #36 from digipost/workflow-runs-null-body
Unngå parsing med Gson dersom response-body fra github-api'et er null
2 parents da3961f + 086c506 commit fc617ac

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ class GithubApiClient(private val githubToken: String) {
5151
val uri: String = GITHUB_WORKFLOW_RUNS_URI.format(repo.owner, repo.name, datetimeRange(days), days)
5252
val request: HttpRequest = githubApiRequest(uri)
5353
val response: HttpResponse<String> = client.send(request, BodyHandlers.ofString())
54+
55+
if (response.body() == null) {
56+
logger.warn("Null body received when fetching workflow runs for ${repo.name}")
57+
return emptyList()
58+
}
59+
5460
val workflowRuns: WorkflowRuns = Gson().fromJson(response.body(), WorkflowRuns::class.java)
5561
return workflowRuns.workflowRuns?.filter { it.isScheduledContainerScan() } ?: run {
5662
logger.warn("workflowRuns is Null. repositoryname={}", repo.name)

0 commit comments

Comments
 (0)