Skip to content

[Bug]: PR Code tab shows a 0/0, patch-less file as an empty file #43482

Done

Description

@kaimo455

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web; packages/source-control-github

Summary

#31404 was closed by #31419 (changed files are now read 30 per page), but the zero-count case it described is still rendered as a complete empty file. When GitHub returns a file with additions: 0, deletions: 0 and no patch, toFilesPatch records the omission only when additions + deletions > 0 (packages/source-control-github/src/server/gitHubPullRequestJson.ts:1865-1873 on main). A zero-count, patch-less entry therefore escapes the omittedFileStats / truncated path and expands to nothing, with no +/− counts.

The follow-up on that issue already noted that 30 per page does not fix every PR: on a 25-file PR, per_page=30 still returned seven zero-count, patch-less entries, and only per_page=5&page=5 returned their real counts and patches.

Steps to reproduce

  1. Find a PR where GET /repos/{owner}/{repo}/pulls/{number}/files?per_page=30 returns at least one entry like this, with no patch field:
    {"filename":"example.ts","status":"modified","additions":0,"deletions":0}
    A public repro was described in [Bug]: PR Code tab shows empty file diffs when GitHub omits patches on large API pages #31404; it still reproduces with the current 30-per-page setting.
  2. Open that PR's Code tab in T3.
  3. The row shows no addition/deletion counts, and expanding it shows an empty file.
  4. Request the same file with per_page=5&page=5 (or any smaller page): it comes back with real counts and a patch.

Expected behavior

A missing patch should be distinguishable from an empty change. Zero-count, patch-less entries should be detected as withheld: recover them with smaller pages or on demand, or show an explicit "diff unavailable" state instead of an empty file.

Actual behavior

The file renders without counts and expands to an empty diff. The omission check requires nonzero counts, so the incorrect zero-count responses are treated as complete files.

Impact

Major degradation or frequent failure: parts of a large PR cannot be reviewed in T3.

Version or commit

v0.1.12 (2026-11-25); the same code is on main at a95cb67.

Environment

GitHub.com pull requests; T3 Code desktop.

Workaround

View the file on github.com, or use gh pr diff / git show.

Logs or stack traces

Anonymized files API response shape replayed through decodePullRequestFilesJson:

[{"filename":"example.ts","status":"modified","additions":0,"deletions":0}]

The actual file is nonempty text; a smaller page returns it with real counts and a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions