Skip to content

check_suite.rerequested handler fails with "head_sha wasn't supplied" when re-running dry-run check via GitHub UI #1015

Description

@StephHope

Problem Description

What is actually happening

When re-running the "Safe-setting validator" check via the GitHub UI (clicking Re-run on the check suite/check run for a dry-run PR check), GitHub Actions fails with:

Invalid request.

"head_sha" wasn't supplied.

This error was observed in our application logs — the GitHub UI itself gives no useful error information.

The check_suite.rerequested handler in index.js calls createCheckRun(context) with no arguments:

robot.on(['check_suite.rerequested'], async context => {
  robot.log.debug('Check suite was rerequested!')
  return createCheckRun(context)
})

(Note: this handler is also registered twice, back-to-back, with identical bodies.)

But createCheckRun requires head_sha to build the checks.create payload:

async function createCheckRun (context, pull_request, head_sha, head_branch) {
  const { payload } = context
  const res = await context.octokit.rest.checks.create({
    owner: payload.repository.owner.login,
    repo: payload.repository.name,
    name: 'Safe-setting validator',
    head_sha
  })
  ...
}

Since no head_sha is passed in on rerequest, head_sha is undefined, and the checks.create REST call is sent without it — which the Checks API requires — producing the error above.

By contrast, every other call site (check_suite.requested, pull_request.opened, pull_request.reopened) correctly pulls head_sha out of the payload (e.g. context.payload.check_suite.head_sha or payload.pull_request.head.sha) before calling createCheckRun.

What is expected behavior

Re-running the dry-run check via the GitHub UI should re-trigger the "Safe-setting validator" check run successfully, the same way the initial check suite creation does.

The check_suite.rerequested handler should extract head_sha, head_branch, and pull_request from context.payload.check_suite (same as the existing check_suite.requested handler) and pass them into createCheckRun. The duplicate handler registration should also be removed.

Error output, if available

Invalid request.

"head_sha" wasn't supplied.

Context

Are you using the hosted instance of probot/settings or running your own?

Running our own instance.

If running your own instance, are you using it with github.com or GitHub Enterprise?

github.com

Version of probot/settings

2.1.20-rc.3 (main-enterprise @ 4578aea)

Version of GitHub Enterprise

N/A (github.com)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions