Learning center

How do you record an emergency merge that bypassed review?

Let one named team bypass in "For pull requests only" mode, so every emergency merge is a pull request. Open an exception record when the merge happens, naming who bypassed, which rules and checks were skipped, and who reviews the change afterward. Close it when that review is done and the skipped checks have run on the merged commit.

Who should be able to bypass#

An emergency merge usually skips one of two things: the required approval, because no reviewer is available, or a required check, because it is broken for reasons unrelated to the fix. Both are rules in a ruleset, and the bypass list decides who can skip them.

Give that ability to one small team, in pull request mode. GitHub documents that mode as one where "The selected actor is now required to open a pull request to make changes to a repository, creating a clear trail of their changes in the pull request and audit log. The actor can then choose to bypass any branch protections and merge that pull request." Granting bypass permissions For a fictional organization, acme, with an incident team whose ID is made up here, the ruleset's bypass entry is:

"bypass_actors": [
  { "actor_id": 4410982, "actor_type": "Team", "bypass_mode": "pull_request" }
]

Two alternatives are worse. Disabling the ruleset during the incident lifts every rule in it for everyone until someone turns it back on, and the bypass list guide explains why a broad role on the list hides who used it. On classic branch protection with admins exempt, every admin can merge past the rules, and only organization owners can read the audit log entry that results. The administrator bypass guide covers moving that power to a team.

What GitHub records for you#

A bypass leaves three kinds of evidence. Rule insights lists actions where someone "bypassed one or more rulesets," filterable by ruleset, branch, actor and time period, and shows which rules required the bypass. Viewing insights for rulesets The rule suites API returns the same events. Each has an actor, the ref, before_sha and after_sha, and a result of bypass, and fetching one with include_metadata=true adds pull request details, including reviews, for pull request rule evaluations. REST API endpoints for rule suites For classic branch protection, the organization audit log records protected_branch.policy_override, "A branch protection requirement was overridden by a repository administrator." Audit log events for your organization

These records say what happened. They do not say why, and they do not track the review that the merge skipped. They also expire: the rule suites API's time_period filter reaches back at most a month, and the organization audit log covers 180 days and is readable only by owners. Reviewing the audit log An exception record fills those gaps.

A worked exception#

Suppose acme/payments-api requires one approval and the test check on main. At 02:10 UTC a bad configuration value starts failing refunds. The on-call engineer, a member of the incident team, opens a pull request that restores the previous value. The test job is failing on main for an unrelated reason, a dependency mirror that is down, and no second engineer is awake. The engineer merges with the bypass at 02:24 UTC and opens this record as an issue, linked from the pull request:

## Exception: bypassed merge to main

- Pull request: (link to the merged pull request)
- Merged commit: 3f9c2a1
- Bypassed by: (GitHub handle), incident team
- Ruleset and rules bypassed: "main: review and tests" / 1 required approval, required check `test`
- Why: refunds failing since 02:10 UTC; `test` red on main because the dependency mirror is down
- Checks that did not run on this commit: `test`
- Follow-up reviewer: (handle from the owning team), due by end of next working day
- Closes when: the follow-up review is recorded below, and `test` has passed on 3f9c2a1 or a later commit that contains it

The record names the skipped evidence explicitly. The reviewer knows the change got no approval and that test never ran on it, so the follow-up checks both. A bare "emergency, merged" comment leaves the reviewer to work out what was skipped.

The follow-up that closes it#

The follow-up review is the part people skip once the incident is over. Make it a task with a person and a date, then work it in this order:

  1. Run the skipped checks on the merged commit once their cause is fixed, and link the passing run in the record.
  2. Have the follow-up reviewer read the merged diff with the same scrutiny as a normal review and write their conclusion in the record. If they find a problem, the fix goes through the normal path as a new pull request, linked from the record.
  3. Compare the record with the rule insights entries for the same time window, filtered by actor to the incident team's members. Each bypass in that window should have a record. One without a record is an exception nobody explained.
  4. Close the record.

Step 3 is also how you find unrecorded exceptions in general. Run it on a schedule:

gh api --paginate \
  "repos/acme/payments-api/rulesets/rule-suites?rule_suite_result=bypass&time_period=month&per_page=100" \
  --jq '.[] | [.pushed_at, .actor_name, .ref, .after_sha] | @tsv'

Each line is a bypass: its time, actor, ref and resulting commit. Match each one to a record by commit SHA.

What the record does not catch#

A record is only as reliable as the habit of writing it. It does not stop a bypass actor from using the bypass for something that was not an emergency; the monthly comparison only makes that visible afterward. It does not cover exceptions that never register as bypasses: an exempt actor's pushes run no rules, and a ruleset switched to Disabled stops evaluating anything. Watch for the latter in the organization audit log's repository_ruleset.update events, which include the old and new enforcement.

The decision#

Before the next incident, put one team on the bypass list in pull request mode, publish the record template where on-call engineers will find it, and name the owning team for each protected path, so the follow-up reviewer is known in advance. After each bypass, open the record within the hour, and close it only when the skipped checks have passed and a reviewer has read the change.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading