GitHub: the diff of a pull request answered 406, or files are missing
GitHub's REST API gives a pull request's changes in two ways: the whole diff, when the pull request (GET /repos/OWNER/REPO/pulls/NUMBER) is asked for with the media type application/vnd.github.diff, and the list of changed files (GET /repos/OWNER/REPO/pulls/NUMBER/files), with each file's patch. Both stop at a number of files. The answers below are what api.github.com said on October 25, 2026 for a public pull request with 1,545 changed files, with the rules from GitHub's documentation behind them.
HTTP/1.1 406 Not Acceptable
{"message":"Sorry, the diff exceeded the maximum number of files (300). Consider using 'List pull requests files' API or locally cloning the repository instead.",
"errors":[{"resource":"PullRequest","field":"diff","code":"too_large"}]}
406 "too_large": the diff has more than 300 files
- The diff comes in one answer, and GitHub does not make it for a pull request that changes more than 300 files: it answers 406 Not Acceptable, with the code
too_largeon the fielddiff, and points to the list of files. The same pull request as JSON (application/vnd.github+json) answered 200; only the diff was refused. - Also over 20,000 lines: GitHub refuses the diff the same way when it is too long, with the same
too_largecode ondiffand the messageSorry, the diff exceeded the maximum number of lines (20000). On November 5, 2026 two public pull requests answered this: one with 71 files and 40,969 lines added and deleted, and one with 149 files and only 15,261 (theadditionsplusdeletionsof the pull request). Fewer than 300 files, or fewer than 20,000 changed lines, do not rule it out.
To review a pull request too large for the diff: Pull Request Inbox for GitHub, a plugin for JetBrains IDEs, reads the changes from the list of files, 100 a page, up to the 3,000 files GitHub gives, so the diff's limit of 300 files does not apply, and opens each file in the IDE's diff.
The list of files stops at 3,000
- At most 3,000 files: GitHub's documentation says the list includes a maximum of 3,000 files, 30 a page by default and up to 100 with
per_page. TheLinkheader'srel="last"names the last page; a page after it answered 200 with an empty list. - To tell whether files are missing, compare the number of files you received with
changed_filesin the pull request itself (GET /repos/OWNER/REPO/pulls/NUMBER): for the pull request above it was1545, all of them in 16 pages of 100. - 404
Not Found: no pull request has that number, or your token cannot see the repository: GitHub answers 404, not 403, for a private repository you cannot access (see which permission to add). The documentation also lists 422 (validation failed, or the endpoint has been spammed), 500 and 503 for this list.
What to do
- 406: read the list of files instead, or compare the branches yourself:
git fetch origin pull/NUMBER/headgets the pull request's head (GitHub keeps it under that ref), andgit diff origin/BASE...FETCH_HEADshows every file, as GitHub's Files changed does. - One commit at a time:
GET /repos/OWNER/REPO/commits/REFwith the default JSON media type pages a commit whose diff has more than 300 files: the response carries paginationLinkheaders for the remaining files, up to a limit of 3,000 files, and each page has the same commit information, only the file list changes (GitHub's get a commit). - A commit's diff can time out: asking the same endpoint for
application/vnd.github.difforapplication/vnd.github.patchtakes no pagination parameters, and larger diffs may time out and return a 5xx status code. With the patch, diffs with binary data have no patch property (GitHub's get a commit). - More than 3,000 files: the API does not give the rest; use the same
git diff. - Just the counts:
git diff --shortstat origin/BASE...FETCH_HEADprints only the total number of changed files and of added and deleted lines.--numstatgives the added and deleted lines for each file with the full path, and two-for a binary file instead of 0 0 (git diff). - On the web: the Files changed tab has its own limits on lines, size and files, and hides generated files by default (see file diff not shown).
gh pr diffgets the same 406: the GitHub CLI asks for the pull request withapplication/vnd.github.v3.diff(application/vnd.github.v3.patchwith--patch), and--name-onlyreads the names out of that same diff (pkg/cmd/pr/diff/diff.go). On the 71-file pull request above, gh 2.96.0 printedcould not find pull request diff: HTTP 406and exited 1, both with--name-onlyand with--patch.gh api repos/OWNER/REPO/pulls/NUMBER/files --paginate --jq '.[].filename'listed all 71 files; a reply on the GitHub CLI issue cli/cli#10712 gives the same workaround.gh pr diff --webopens the Files changed tab instead.- A diff that looks broken: GitHub's reference for get a pull request says to pass the media type for the diff or patch format, and that if a diff (
application/vnd.github.diff) is corrupt, you contact GitHub through the GitHub Support portal with the repository name and the pull request ID. The 406 answers above point to the same page indocumentation_url.
In IntelliJ IDEA: the changes come from the list of files, never from the diff
Checked in the IntelliJ IDEA source on October 31, 2026: GHPRChangesServiceImpl.kt, GHPRChangesDataProviderImpl.kt, GithubApiRequests.kt, GithubApiPagesLoader.kt.
To read the changes of a pull request, the IDE sends these requests:
GET /repos/OWNER/REPO/pulls/NUMBER/files
GET /repos/OWNER/REPO/commits/SHA
GET /repos/OWNER/REPO/compare/BASE...HEAD
It never asks for a pull request as a diff. Its only request with the diff media type compares two commits, so the 406 too_large above does not come from the IDE.
The changes of the whole pull request come from the first one, the list of files above. It is asked for without per_page, so 30 a page by GitHub's default, and followed through GitHub's next links until there are none. So the IDE has at most the 3,000 files the list gives.
The changes of each commit come from the commit itself, up to 50 commits at a time, also followed through the next links. The merge base comes from comparing the base and head commits of the pull request.
GitHub pull requests in IntelliJ IDEA
Pull Request Inbox for GitHub, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, reads a pull request's changes from the list of files, 100 a page, up to the 3,000 files GitHub gives, so the diff's limit of 300 files does not apply to it. Each file opens in the IDE's diff, from the merge base of the target branch to the head commit, as GitHub's Files changed shows it. For a pull request with more than 3,000 changed files, the Files tab says only the first ones are listed, and git diff shows the rest. The review inbox, diffs and conversations are free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
GitHub is a trademark of GitHub, Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitHub, Inc. or JetBrains.
More: GitHub merge refused (405, 409) · GitHub review refused (422) · GitHub search 422 "Validation Failed" · "Resource not accessible by personal access token" · 401 "Bad credentials" · "Resource protected by organization SAML enforcement" · "API rate limit exceeded" · GitHub line comment 422 "must be part of the diff" · GitHub branch update refused (422) · GitHub pull request not created (422, 403) · GitHub auto-merge refused · GitHub draft, ready for review or close refused · GitHub conversation not resolved · GitHub checks not shown (check runs 403) · GitHub file contents not read · GitHub compare refused (404, 422) · GitHub comment or reply refused (403 locked, archived) · GitHub merge method not allowed (405) · GitHub branch not found (404, 301) · GitHub Enterprise Server not reached · GitHub review request not shown · GitHub pull request list incomplete · GitHub 404 Not Found, renamed repositories (301, 307) · GitHub line comment outdated or not on the diff · GitHub pull requests not updating, notifications late · GitHub suggested change cannot be applied · GitHub required check stuck at "Expected" · GitHub code owner review required · GitHub merge blocked by unresolved conversations · GitHub merge blocked by unsigned commits · GitHub branch that merges through a merge queue · GitHub merge waiting for an approval of the most recent push · GitHub merge waiting for code scanning results · GitHub merge waiting for code quality results · GitHub merge blocked by a code coverage threshold · GitHub merge blocked by license compliance results · GitHub branch locked or its updates restricted · GitHub branch not deleted after merging · GitHub merge waiting for a team's approval (Required reviewers) · GitHub merge blocked by secret scanning alerts · GitHub stacked pull request not merging · GitHub push blocked by push rules · GitHub merge blocked by commit metadata rules · GitHub force push blocked · GitHub issue not closed by a merged pull request · GitHub pull request not checked out locally · GitHub pull request has merge conflicts · GitHub changes requested and dismissing a review · GitHub co-author not credited for a commit · GitHub dependency review check failed · GitHub Dependabot not rebasing its pull request · GitHub fork not syncing with upstream · GitHub pull request base branch not changing · GitHub pull request not reverting · GitHub pull request template not showing · GitHub pull request labels or assignees not added · GitHub pull request not closing or reopening · GitHub push blocked by push protection · GitHub pull request comment hidden · GitHub pull request blocked until deployments succeed · GitHub team review request replaced by members · GitHub pull request file no longer marked Viewed · GitHub pull request marked merged without being merged · GitHub Copilot review does not count as an approval · GitHub checks not running on a pull request a workflow created · GitHub Update branch button not shown on a pull request · GitHub checks failing on a Dependabot pull request · GitHub checks failing on a pull request from a fork · GitHub checks skipped by [skip ci] in a commit message · GitHub checks gone after the retention period · GitHub code review limits in a public repository · GitHub pull requests turned off or limited in a repository · GitHub checks run on every pull request in a stack · GitHub pull request showing commits already squash merged · GitHub pull request not showing a file diff · GitHub push to a pull request branch from a fork refused · GitHub check cancelled on a pull request · GitHub Rebase and merge not available · GitHub merge commit message not what you expected · GitHub pull request shows every line changed · GitHub API request timed out · GitHub pull request image or document diff not shown · GitHub review request refused (422) · GitHub pull request from Copilot: checks not running, approval not counted · GitHub push refused: GH006 and GH013 on a protected branch · GitHub "At least 1 approving review is required", approvals that do not count · GitHub pull request plugins for IntelliJ IDEA, compared · 日本語