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.
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. - More than 3,000 files: the API does not give the rest; use the same
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).
In IntelliJ IDEA: the changes come from the list of files, never from the diff
How the GitHub support built into IntelliJ IDEA reads a pull request's changes, in its source (checked October 31, 2026; IntelliJ IDEA: GHPRChangesServiceImpl.kt, GHPRChangesDataProviderImpl.kt, GithubApiRequests.kt, GithubApiPagesLoader.kt):
- 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_largeabove does not come from the IDE. - The whole pull request's changes come from the list of files above, 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 it has at most the 3,000 files the list gives. - Each commit's changes come from the commit itself (
GET /repos/OWNER/REPO/commits/SHA), up to 50 commits at a time, also followed through the next links. The merge base comes from comparing the pull request's base and head commits (GET /repos/OWNER/REPO/compare/BASE...HEAD).
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).
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 · 日本語