transplants: warn on zero-byte binary file additions (bug 1709608) #1157 (lando@main)
| Warnings |
|
|---|---|
| Blockers |
|
| Branches | bug1709608/warn-zero-byte-binary -> main |
| Repo | lando@main (git) (git://github.com/tnikkel/lando.git) |
| Author | tnikkel |
| State | open |
| Commit Title | transplants: warn on zero-byte binary file additions (bug 1709608) |
| Commit Body | ## Summary Surface zero-byte binary file additions to the landing user as a warning that must be acknowledged before landing. Bug 1709608 has recurred multiple times since 2021: when Lando lands using a Phabricator diff whose `creationMethod` is `commit` (the auto-generated diff Phabricator creates from a landed commit), binary file payloads have been stripped, so the file lands as 0 bytes. Most recently this hit bug 2034984 (test + reference images in a reftest both landed as 0 bytes, causing the comparison to silently pass and removing test coverage with no signal) and bug 2005089 (Android sample-app launcher icons landed as 0 bytes). The 2023-12 fix in #364 only covered the uplift creation path; non-uplift relands remain vulnerable. As an interim safety net, this PR adds a warning that inspects the rendered patch and surfaces any zero-byte binary additions. A follow-up can add a targeted blocker that uses `differential.querydiffs` to detect the regression case (binary file went from non-zero to zero between diff versions on the same revision) and block automatically, without bothering authors of legitimately-empty binary fixtures. The new `PreventEmptyBinaryCheck` is written as a neutral detection primitive (no warn/block opinion in its message) so a future blocker can reuse it unchanged. Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1709608 ## Test plan - [x] New unit tests in `src/lando/utils/tests/test_landing_checks.py` cover: text-only diff, non-empty binary addition, binary deletion, empty binary addition (the bug 1709608 signature), and a mixed diff (only the empty addition is reported). - [ ] Manual smoke: trigger a landing of a revision whose active diff was sourced from a landed commit and confirm the warning appears. |
Landings
Not yet Landed
There has been no attempt to land revisions in this stack.