PR checks: an empty file or a pure rename is not a binary #508

Open
hmodymac8-droid wants to merge 2 commits from upstream-pr/513 into main
hmodymac8-droid commented 2026-11-24 01:08:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by hmodymac8-droid on 2026-11-24T01:08:02Z.


pr-check.yml marks a file as binary when GitHub's files API shows no patch and 0 changed lines ((.patch == null) and (.changes == 0)). That is also what the API returns for an empty file, a pure rename and a mode-only change, so pr_check.py refuses such a PR with "<file> is a binary file outside tests/data/ or over 1 MB", although nothing binary was added. Moving a script or adding a .gitkeep is enough to hit it.

Reproduced on a throwaway PR in my fork (since closed): a pure rename of scripts/re/pe_exports.py, an empty scripts/re/.gitkeep and a real PNG header in docs/picture.png. The files API returned binary = true for all three:

  • main's pr_check.py refuses all three files
  • with this PR, only docs/picture.png is refused

What is in it

  • scripts/pr_check.py: when the workflow marks a file binary, blob_is_binary() reads the blob (git/blobs API, or git cat-file -p with --local) and keeps the mark only if the content is binary by git's own test (looks_binary(): a NUL byte in the first 8000 bytes; an empty file is not binary). If the blob can't be read, the workflow's answer stands. check() and pr-check.yml are unchanged.
  • scripts/test_pr_check.py (from #507): a BinaryContentTests class with looks_binary(), plus end-to-end --local runs. An empty file and a renamed text file pass; a new PNG and a renamed binary are still refused.

Tested

  • Windows 11 Pro 26200, Python 3.13, AMD Radeon RX 7700 XT (driver 32.0.32029.2010), Rust 1.100.0
  • python test_pr_check.py (in scripts/): OK, together with #507's tests. Against main's pr_check.py the empty file and the rename are refused (and looks_binary does not exist)
  • the API path (no --local) on the real files list of the probe PR above: results as listed
  • python scripts/pr_check.py --local on this description: description ok
  • cargo test --workspace -- --test-threads=4 at 2997c9a: 676 passed, 0 failed, 41 ignored, no SKIPPED (results in #42)

Regression run

  • not needed: no file under crates/xcl/src changes

Not tested

  • a run of pr-check.yml itself (it uses main's pr_check.py, so this takes effect after merge)

AI use

  • Claude Code (Claude Opus 5.5) found the problem, reproduced it through the API, wrote the fix and the tests.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5464124381 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/513). Originally posted by [hmodymac8-droid](https://github.com/hmodymac8-droid) on 2026-11-24T01:08:02Z. --- `pr-check.yml` marks a file as binary when GitHub's files API shows no patch and 0 changed lines (`(.patch == null) and (.changes == 0)`). That is also what the API returns for **an empty file, a pure rename and a mode-only change**, so `pr_check.py` refuses such a PR with "`<file>` is a binary file outside tests/data/ or over 1 MB", although nothing binary was added. Moving a script or adding a `.gitkeep` is enough to hit it. Reproduced on a throwaway PR in my fork (since closed): a pure rename of `scripts/re/pe_exports.py`, an empty `scripts/re/.gitkeep` and a real PNG header in `docs/picture.png`. The files API returned `binary = true` for all three: - `main`'s `pr_check.py` refuses all three files - with this PR, only `docs/picture.png` is refused **What is in it** - `scripts/pr_check.py`: when the workflow marks a file binary, `blob_is_binary()` reads the blob (`git/blobs` API, or `git cat-file -p` with `--local`) and keeps the mark only if the content is binary by git's own test (`looks_binary()`: a NUL byte in the first 8000 bytes; an empty file is not binary). If the blob can't be read, the workflow's answer stands. `check()` and `pr-check.yml` are unchanged. - `scripts/test_pr_check.py` (from #507): a `BinaryContentTests` class with `looks_binary()`, plus end-to-end `--local` runs. An empty file and a renamed text file pass; a new PNG and a renamed binary are still refused. **Tested** - Windows 11 Pro 26200, Python 3.13, AMD Radeon RX 7700 XT (driver 32.0.32029.2010), Rust 1.100.0 - `python test_pr_check.py` (in `scripts/`): OK, together with #507's tests. Against `main`'s `pr_check.py` the empty file and the rename are refused (and `looks_binary` does not exist) - the API path (no `--local`) on the real files list of the probe PR above: results as listed - `python scripts/pr_check.py --local` on this description: `description ok` - `cargo test --workspace -- --test-threads=4` at `2997c9a`: 676 passed, 0 failed, 41 ignored, no `SKIPPED` (results in #42) **Regression run** - not needed: no file under `crates/xcl/src` changes **Not tested** - a run of `pr-check.yml` itself (it uses `main`'s `pr_check.py`, so this takes effect after merge) **AI use** - Claude Code (Claude Opus 5.5) found the problem, reproduced it through the API, wrote the fix and the tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wadzwigidy commented 2026-11-24 07:05:17 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by wadzwigidy on 2026-11-24T01:32:04Z.


Independent check of PR #513 at 15e3d8800a5b918066e9480072a4c2802276cfb7.

Tested

  • Windows 11 build 26300, AMD Ryzen 9 5900X, NVIDIA RTX 4080 SUPER (driver 32.0.16.2135; GPU not used), Python 3.14.9.
  • py -3.14 scripts/pr_check_binary_tests.py -v: 4 passed, 0 failed. The tests accept an empty file and a text rename, and still reject a PNG and a renamed binary.
  • git diff --check on the PR commit: clean; worktree clean. Tests used synthetic files only. Temporary files and the checkout were kept on the VS Projects share.

Not tested

  • The live GitHub API path, pr-check.yml after merge, or the Rust/GPU suite.

AI use

  • Codex (GPT-6; exact model identifier not exposed to this session) assisted with the local check and this report. No game files were used.
<!-- greyfinch-sync:ivall/xcl:comment:7119194340 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/513#issuecomment-7119194340). Originally posted by [wadzwigidy](https://github.com/wadzwigidy) on 2026-11-24T01:32:04Z. --- Independent check of PR #513 at `15e3d8800a5b918066e9480072a4c2802276cfb7`. **Tested** - Windows 11 build 26300, AMD Ryzen 9 5900X, NVIDIA RTX 4080 SUPER (driver 32.0.16.2135; GPU not used), Python 3.14.9. - `py -3.14 scripts/pr_check_binary_tests.py -v`: 4 passed, 0 failed. The tests accept an empty file and a text rename, and still reject a PNG and a renamed binary. - `git diff --check` on the PR commit: clean; worktree clean. Tests used synthetic files only. Temporary files and the checkout were kept on the VS Projects share. **Not tested** - The live GitHub API path, `pr-check.yml` after merge, or the Rust/GPU suite. **AI use** - Codex (GPT-6; exact model identifier not exposed to this session) assisted with the local check and this report. No game files were used.
DavidM1911 commented 2026-11-25 14:10:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T13:53:45Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7164446621 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/513#issuecomment-7164446621). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T13:53:45Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
github-actions[bot] commented 2026-11-29 20:41:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:41:38Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7262283123 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/513#issuecomment-7262283123). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:41:38Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 03:37:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:37:54Z.


Triage (#1607) – head 2e1eb8c

No open or merged PR makes the same change. On main, .github/workflows/pr-check.yml still marks a file binary when (.patch == null) and (.changes == 0), and pr_check.py trusts that flag. #952 also touches renames in pr_check.py, but only for the smoke requirement.
No problems found in the diff. Note: in remote mode each flagged file now costs one gh api .../git/blobs call that downloads the whole blob, including real binaries up to 100 MB.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7299905236 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/513#issuecomment-7299905236). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:37:54Z. --- **Triage (#1607)** – head 2e1eb8c No open or merged PR makes the same change. On main, `.github/workflows/pr-check.yml` still marks a file binary when `(.patch == null) and (.changes == 0)`, and `pr_check.py` trusts that flag. #952 also touches renames in `pr_check.py`, but only for the smoke requirement. No problems found in the diff. Note: in remote mode each flagged file now costs one `gh api .../git/blobs` call that downloads the whole blob, including real binaries up to 100 MB. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/513:upstream-pr/513'
git switch 'upstream-pr/513'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/513'
git switch 'upstream-pr/513'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/513'
git switch 'upstream-pr/513'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/513'
git switch 'main'
git merge --squash 'upstream-pr/513'
git switch 'main'
git merge --ff-only 'upstream-pr/513'
git switch 'main'
git merge 'upstream-pr/513'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!508
No description provided.