Sub topic 16
Bypass permissions and known limits
This chapter assumes you can write a CODEOWNERS file and turn on required code owner review in a branch protection rule or ruleset. It covers who can skip that requirement and what the feature does not do.
Who can bypass required review
Required code owner review only blocks merges for people the rule applies to. Which people that is depends on the mechanism you used.
| Mechanism | How bypass works |
|---|---|
| Branch protection | Repository admins can merge past the rules unless "Do not allow bypassing the above settings" is on. The API field for this is `enforce_admins`. |
| Branch protection | "Allow specified actors to bypass required pull requests" lets named users, teams, or apps skip the pull request requirement. |
| Rulesets | The bypass list names roles, teams, or apps. Each entry has a mode: "Always", or "For pull requests only". |
In a ruleset, "For pull requests only" is the safer mode. Those actors can skip the rule only through a pull request. They cannot push directly to the branch.
Keep bypass lists short and give them to teams, not individuals. Review them on a schedule. Anyone on the list can ship changes to protected paths without the owning team seeing them.
Known limits
- Owners need write access. An owner without write access to the repository is ignored. A team must have explicit write access, and it must be visible to the repository. Inherited access does not count.
- Invalid entries are skipped. An unknown user, a misspelled team, or an email that matches no account produces no review request and no approval. GitHub flags these as errors on the file's page. Other lines still work.
- Size cap. A CODEOWNERS file larger than 3 MB is not loaded. No owners are requested at all. Large monorepos should consolidate patterns, not list every file.
- Syntax differs from .gitignore. CODEOWNERS does not support
!negation,[ ]character ranges, or escaping a leading#. Lines that rely on these do not behave as they would in.gitignore. - Drafts. Owners are not requested automatically while a pull request is a draft. Requests go out when it is marked ready for review.
- Authors can't approve their own work. If the author is the only owner of a changed file, their approval does not count, and someone else with write access to the owner scope must approve.
- Only owned files matter. If a pull request touches no owned path, no code owner approval is required. Unowned paths are not protected by this feature.
Choosing a bypass policy
Decide who really needs to skip review, and write down why. Typical cases are an incident responder who must ship a hotfix, or a release bot that merges version bumps. Give each case the narrowest actor and the "pull requests only" mode where possible.
Exercise
Your branch protection rule requires code owner review, but a repository admin merged a pull request that touched an owned file without any owner approving it. Name two settings you would check.
Show answer
First, check whether "Do not allow bypassing the above settings" (enforce_admins) is enabled. If it is off, admins can bypass the rule. Second, check whether the admin or their team appears in "Allow specified actors to bypass required pull requests". For a ruleset, check its bypass list instead.