Skip to content

Commit

Permalink
Fix processing for check run events (#250)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bluekeyes authored Jun 4, 2021
1 parent 53d832d commit b926206
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/handler/check_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,23 @@ func (h *CheckRun) Handle(ctx context.Context, eventType, deliveryID string, pay
}

for _, pr := range prs {
logger := logger.With().Int(githubapp.LogKeyPRNum, pr.GetNumber()).Logger()
ctx := logger.WithContext(ctx)

// The PR included in the CheckRun response is very slim on information.
// It does not contain the owner information or label information we
// need to process the pull request.

fullPR, _, err := client.PullRequests.Get(ctx, repo.GetOwner().GetLogin(), repo.GetName(), pr.GetNumber())
if err != nil {
return errors.Wrapf(err, "failed to fetch PR number %q for CheckRun", pr.GetNumber())
}
pullCtx := pull.NewGithubContext(client, fullPR)

logger := logger.With().Int(githubapp.LogKeyPRNum, pr.GetNumber()).Logger()
config, err := h.FetchConfig(ctx, client, pr)
config, err := h.FetchConfig(ctx, client, fullPR)
if err != nil {
return err
}
if err := h.ProcessPullRequest(logger.WithContext(ctx), pullCtx, client, config, fullPR); err != nil {
if err := h.ProcessPullRequest(ctx, pullCtx, client, config, fullPR); err != nil {
logger.Error().Err(errors.WithStack(err)).Msg("Error processing pull request")
}
}
Expand Down

0 comments on commit b926206

Please sign in to comment.