reviewdog: GitHub Pull Request diff API responds with 406 — diff too large

We’ve started seeing several of our GitHub actions builds with reviewdog fail this morning because the GitHub API is returning a 406 error code on diffs larger than 3,000 lines. This seems to be new GitHub API behavior because the same version of reviewdog worked was passing on these same PRs three days ago.

The error message currently has no relevant Google results. Searching around on GitHub, I only find one mention of Code:too_large with field: diff anywhere, and it’s from another reviewdog user today: https://github.com/platformsh/platformsh-docs/pull/3885#issuecomment-2018746515

We’ve seen this both when running from actions like https://github.com/reviewdog/action-brakeman and from custom actions that invoke reviewdog manually.

An example reviewdog error when running with reviewdog -name=Hadolint -reporter=github-check -efm='%f:%l %m' -level=warning:

reviewdog: post failed for Hadolint: fail to parse diff: 
GET https://api.github.com/repos/thedyrt/<redacted>/pulls/<redacted>: 
406 Sorry, the diff exceeded the maximum number of lines (3000)
 [{Resource:PullRequest Field:diff Code:too_large Message:}]

The API response from GitHub:

{
  "message": "Sorry, the diff exceeded the maximum number of lines (3000)",
  "errors": [
    {
      "resource": "PullRequest",
      "field": "diff",
      "code": "too_large"
    }
  ],
  "documentation_url": "https://docs.github.com/rest/pulls/pulls#get-a-pull-request"
}

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 25
  • Comments: 26 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Currently, this issue is only resolved when the reporter is github-pr-review. Therefore, I think that github-check, github-pr-check and github-pr-annotations also need to be resolved.

It seems possible to work around this using the PR files API in many cases, but it’s not a drop-in replacement. The files JSON response still returns the patch text, but it’s not in the same multi-file format that the other endpoint returns. The docs claim that the files API can return results in the same application/vnd.github.diff format as the base PR API, but this doesn’t seem to actually work. Setting Accept: application/vnd.github.diff still seems to return JSON. I have an inquiry in to GitHub support about whether this is a bug or if the docs are wrong.

Is there a reason that we need to be fetching this diff from GitHub instead of just using git to generate it locally from the repo? Is there an existing DiffService that already does this that we could use as fallback?

https://github.com/massongit/action-android-lint-example/actions/runs/12255678175/job/34189298844#step:2:57

 #8 0.537 reviewdog/reviewdog info found version: 0.20.3 for v0.20.3/Linux/x86_64

https://github.com/massongit/action-android-lint-example/actions/runs/12255678175/job/34189298844#step:7:13

time=2024-12-10T12:04:54.823Z level=INFO msg="reviewdog: fallback to use git command"

I prepared a PR https://github.com/massongit/action-android-lint-example/pull/1 with over 300 new files and tried running dvdandroid/action-android-lint@v1.2 with the same options. However, the latest reviewdog was installed and fell back to the git command.

Do the related actions need bumping ?

eg. reviewdog/action-shellcheck etc?

While setting fetch-depth: 0 did solve this specific issue, it caused other problems like running out of disk space, taking 10 minutes to clone, etc. It’s also not ideal that every GitHub user will have to update their checkout rather than this fallback working by default.

I’m not a git expert, but it seems that if we did a fetch like this, using GitHub default env vars, the necessary branch would be available for the subsequent git merge-base command. Thoughts?

/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --no-recurse-submodules --depth=1 $GITHUB_HEAD_REF

https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables

Seeing similar issues with PRs with lots of files. We have an automation to sync assets from designers and it had around 1200 files changed. Failed in the same way but with a different message about to many files.