reviewdog error: diff is empty when agent tried to review a draft PR
Fixes reviewdog runs that abort with an empty diff on pull requests. Use when the reviewdog action logs that the diff is empty, so you can repair the checkout (shallow clones hide the base) or confirm the PR actually has changes, then rerun the review. Key trigger: reviewdog's diff-is-empty failure on a PR run.
TL;DR
reviewdog reports an empty diff when it cannot compute the change set, almost always because the checkout is too shallow to see the base commit, or because the draft PR genuinely has no commits yet. Fetch full history (or at least the base branch) in the workflow checkout, push any missing commits, and rerun. reviewdog needs the base commit locally to build the diff.
reviewdog: diff is empty- Confirm the PR has changes:
gh pr view 123 --json commits --jq '.commits | length'. Expected: a number greater than zero. If zero, push the commits first; there is nothing to review yet. - Fix the checkout in the workflow. With actions/checkout, fetch full history so reviewdog can diff against the base:
- uses: actions/checkout@v4
with:
fetch-depth: 0Expected: the step checks out full history.
- To keep the clone small, fetch just the base ref instead:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- run: git fetch origin ${{ github.base_ref }} --depth=1Expected: the base commit is present; git merge-base HEAD origin/${{ github.base_ref }} prints a SHA.
- Rerun the reviewdog job. Expected: reviewdog logs the files it is checking instead of the empty-diff error.
Use this when
- reviewdog exits with a diff-is-empty error on a PR workflow
- The checkout uses the default shallow fetch
- An agent opened a draft PR before pushing any commits
Not for this skill when
- reviewdog fails with a different error (auth, config, parser); this skill is only the empty-diff case
- The run is on a push to main, not a PR; there is no PR diff to compute by design
- The diff is empty because the linter found nothing; that is a clean run, not a failure
Variant phrasings
- "reviewdog fail to get diff empty"
- "reviewdog action no diff found pull request"
- "reviewdog exits no output shallow checkout"
Why it happens
reviewdog builds its change set by diffing the PR head against the base commit locally. A shallow checkout (the actions/checkout default) omits the base commit, so the diff computes to nothing. Draft PRs opened before the first push add a second cause: there are literally no commits to diff.
Edge cases
fetch-depth: 0on a huge monorepo is slow; prefer fetching just the base ref.- reviewdog's
fail_on_errorstill fails the job on empty diff in some configs; the fix is the checkout, not silencing the flag. - If the workflow checks out the merge commit, make sure the base ref fetch matches
github.base_ref, not the default branch name when the PR targets a release branch.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_f2QeUFo5OYOWf-mLzNJXqg
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.