Skip to content

Commit 1c83745

Browse files
authored
Fix nil pointer dereference in GetGithubAppInstallationLink calls across multiple controllers (#2191)
Signed-off-by: Lorenzo Buitizon <[email protected]>
1 parent a4c0d81 commit 1c83745

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

backend/controllers/cache.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func (d DiggerController) UpdateRepoCache(c *gin.Context) {
4747
c.String(http.StatusInternalServerError, fmt.Sprintf("could not find installation link %v %v", repoFullName, installationId))
4848
return
4949
}
50+
if link == nil {
51+
slog.Error("GitHub app installation link not found", "repoFullName", repoFullName, "installationId", installationId)
52+
c.String(http.StatusInternalServerError, fmt.Sprintf("could not find installation link %v %v", repoFullName, installationId))
53+
return
54+
}
5055
orgId := link.OrganisationId
5156

5257
slog.Info("Processing repo cache update", "orgId", orgId)

backend/controllers/github_comment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
7878
)
7979
return fmt.Errorf("error getting github app link")
8080
}
81+
if link == nil {
82+
slog.Error("GitHub app installation link not found",
83+
"installationId", installationId,
84+
)
85+
return fmt.Errorf("github app installation link not found")
86+
}
8187
orgId := link.OrganisationId
8288

8389
if *payload.Action != "created" {

backend/controllers/github_pull_request.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ func handlePullRequestEvent(gh utils.GithubClientProvider, payload *github.PullR
7676
)
7777
return fmt.Errorf("error getting github app link")
7878
}
79+
if link == nil {
80+
slog.Error("GitHub app installation link not found",
81+
"installationId", installationId,
82+
)
83+
return fmt.Errorf("github app installation link not found")
84+
}
7985
organisationId := link.OrganisationId
8086

8187
ghService, _, ghServiceErr := utils.GetGithubService(gh, installationId, repoFullName, repoOwner, repoName)

0 commit comments

Comments
 (0)