Sub topic 17
Troubleshooting missing requests and blocked merges
This chapter assumes you can write a CODEOWNERS file, know that the last matching pattern wins, and have enabled "Require review from Code Owners" on a branch protection rule or ruleset. It gives a checklist for the two common failures: a review was not requested, and a pull request cannot merge.
Work from the symptom
Start with what you see, then check the likely causes in order.
No review was requested
- Wrong file or branch. GitHub reads CODEOWNERS from the pull request's base branch, not from your feature branch. If you added the file in the same pull request, it has no effect until it is merged. It must also sit in
.github/, the repository root, ordocs/. The first of those that exists is used. - Syntax errors. Open the CODEOWNERS file on GitHub and look for the error banner. Lines with invalid syntax are skipped, so the rule you wrote may not exist.
- A later pattern overrides yours. Because the last match wins, a broad pattern near the bottom can replace a specific one above it. A pattern with no owners also clears ownership.
- The owner cannot be requested. A user or team needs write access to the repository. A team must be visible and in the same organization. An email address must belong to a user account with a verified email.
- The pull request is a draft. Draft pull requests do not automatically request code owners. The requests go out when you mark it ready for review.
The merge is blocked
- A pattern matched an owner you did not expect. For each changed file, find the last matching pattern. Each file needs approval from at least one of its owners.
- A stale approval was dismissed. With
dismiss_stale_reviewson, a new push removes earlier approvals. With last-push approval on, someone other than the pusher must approve the final commit. - The author is the only owner. You cannot approve your own pull request, so it needs another owner or a rule adjustment.
- The owning team has no eligible members. Check team membership and repository access.
- Another rule is blocking. Required status checks, required conversation resolution, or an additional approval count can block the merge even when owners have approved.
You can confirm the protection settings from the command line:
gh api repos/OWNER/REPO/branches/main/protection/required_pull_request_reviewsCheck that require_code_owner_reviews is true and read the approval count.
Exercise
You add /billing/ @example-org/payments in a pull request that also changes files in /billing/. No review is requested from the payments team. Give two possible reasons and how to check each.
Show answer
First, the CODEOWNERS change is only in the pull request, and GitHub reads the file from the base branch, so the rule does not exist yet. Merge the rule first, then open a new pull request. Second, the team may lack write access or visibility, or a later pattern such as a broad * rule may override it. Check the team's repository permissions, then the order of patterns in the file and the error banner on the file's page.