Opening a PR right after pushing runs the dry run twice and posts two comments

Open
#1,139 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

  • #1140 by @TovaBecker — closed without merging

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github, javascript
Domain
ci-cd, devtools

Research direction

Start in index.js and trace the check_suite.requested and pull_request.opened handlers into createCheckRun. Check how existing “Safe-setting validator” check runs for the same head_sha can be found, then add or run focused coverage for the push and PR opening arriving close together. Done means one dry run and one PR comment per commit.

Written by the indexing model from the issue text.

Description

Problem

When a PR is opened within a few seconds of pushing its branch, safe-settings creates two "Safe-setting validator" check runs on the same commit. Both run the dry run, and each posts its own PR comment, so the PR gets two identical comments.

Seen on 3.0.0 (df84f83): two check runs on the same head commit, started 3 seconds apart, and two identical comments.

Cause

Two handlers in index.js call createCheckRun for the same commit:

  1. check_suite.requested fires on the push. If the PR already exists, the payload lists it, so a check run is created.
  2. pull_request.opened fires when the PR is created and always creates a check run.

When the PR is created right after the push (for example gh pr create, or Create pull request right after committing in the web editor), both events see the PR.

Expected

One dry run and one comment per commit.

Possible fix

In createCheckRun, skip creating a check run if a "Safe-setting validator" check run already exists for the same head_sha.

Related: #737 (same symptom after a later push), #1015 (check_suite.rerequested is registered twice, so a re-run can also run twice).

Dominant language
JavaScript
Stars
942
Forks
238
PR merge metrics
No merged PRs in 30d

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github-community-projects/safe-settings

All issues in github-community-projects/safe-settings

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.