Skip to content

Commit b926206

Browse files
authored
Fix processing for check run events (#250)
In 1.13.0, an unrelated refactor used an incomplete pull request object to fetch configuration, resulting in requests that are missing the organization name. Because the config isn't loaded, all further processing for check run events is skipped. Use the complete PR object and also re-order things to make it less tempting to use the plain PR object once the full one is available.
1 parent 53d832d commit b926206

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

server/handler/check_run.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,23 @@ func (h *CheckRun) Handle(ctx context.Context, eventType, deliveryID string, pay
6161
}
6262

6363
for _, pr := range prs {
64+
logger := logger.With().Int(githubapp.LogKeyPRNum, pr.GetNumber()).Logger()
65+
ctx := logger.WithContext(ctx)
66+
6467
// The PR included in the CheckRun response is very slim on information.
6568
// It does not contain the owner information or label information we
6669
// need to process the pull request.
67-
6870
fullPR, _, err := client.PullRequests.Get(ctx, repo.GetOwner().GetLogin(), repo.GetName(), pr.GetNumber())
6971
if err != nil {
7072
return errors.Wrapf(err, "failed to fetch PR number %q for CheckRun", pr.GetNumber())
7173
}
7274
pullCtx := pull.NewGithubContext(client, fullPR)
7375

74-
logger := logger.With().Int(githubapp.LogKeyPRNum, pr.GetNumber()).Logger()
75-
config, err := h.FetchConfig(ctx, client, pr)
76+
config, err := h.FetchConfig(ctx, client, fullPR)
7677
if err != nil {
7778
return err
7879
}
79-
if err := h.ProcessPullRequest(logger.WithContext(ctx), pullCtx, client, config, fullPR); err != nil {
80+
if err := h.ProcessPullRequest(ctx, pullCtx, client, config, fullPR); err != nil {
8081
logger.Error().Err(errors.WithStack(err)).Msg("Error processing pull request")
8182
}
8283
}

0 commit comments

Comments
 (0)