transplants: warn on zero-byte binary file additions (bug 1709608)#1157
transplants: warn on zero-byte binary file additions (bug 1709608)#1157tnikkel wants to merge 1 commit into
Conversation
|
View this pull request in Lando to land it once approved. |
|
Looks good. There's a bit more housekeeping needed:
Thanks! |
24245fe to
791a5dc
Compare
|
791a5dc to
bba0f76
Compare
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 (where both the test and reference image in a reftest 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 mozilla-conduit#364 only covered the uplift creation path; non-uplift relands remain vulnerable. As an interim safety net, add a warning that inspects the rendered patch and surfaces any zero-byte binary additions. A follow-up will 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 legitimate empty-binary fixtures. The new `PreventEmptyBinaryCheck` is written as a neutral detection primitive (no warn/block opinion in its message) so the follow-up blocker can reuse it unchanged.
bba0f76 to
bfa5fd9
Compare
There was a problem hiding this comment.
I don't think we need this addition in the migration file. (1) we should probably only add this to repos one at a time via the admin, and (2) this should be applied to repos that explicitly need it.
I suggest removing this change.
| zcmZ?wbhEHbWMp7uXkdSr1_lE>3=9k!85kJ?7+e9j7+M3l85kIz?VMfFP&3pMz`(EJ | ||
| o&%nUd&(O%n&CtNI%g_nQz5(_qzaP=zsBtDUMI;Cj1_p+T0VKi-RR910 |
| assert "empty.png" in result | ||
| assert "real.png" not in result, ( | ||
| "Non-empty binary additions must not appear in the report." | ||
| ) | ||
| assert "src/bar.cpp" not in result, "Text additions must not appear in the report." |
| assert "empty.png" in result | ||
| assert "1709608" in result |
There was a problem hiding this comment.
Can be more explicit here with the warning message, and more human readable.
| Symptom of bug 1709608: when Lando lands using a Phabricator diff whose | ||
| `creationMethod` is `commit`, binary file payloads have been stripped |
There was a problem hiding this comment.
Would be better to discuss the actual causes (e.g., backouts, reopened revisions, automatically updated revisions, etc.) vs. mentioning creationMethod here, since that is quite low level.
|
|
||
| def next_diff(self, diff: dict): | ||
| # Only flag *additions* of binary files. Modifications and deletions | ||
| # legitimately have zero or partial-binary payloads. |
There was a problem hiding this comment.
Can you clarify what partial-binary payloads means here?
| def result(self) -> str | None: | ||
| if self.empty_binary_files: | ||
| return ( | ||
| "Revision adds zero-byte binary files " |
There was a problem hiding this comment.
We're mixing diff and revision throughout this check. I think we can stick with diff since it is the source of the issue.
| from lando.main.support import LegacyAPIException | ||
| from lando.utils.landing_checks import ( | ||
| DiffAssessor, | ||
| PreventEmptyBinaryCheck, |
There was a problem hiding this comment.
| PreventEmptyBinaryCheck, | |
| PreventEmptyBinaryFileAdditionCheck, |
| Symptom of bug 1709608: diffs sourced from a landed commit have their | ||
| binary payloads stripped by Phabricator, so a re-land using such a diff | ||
| silently produces empty binary files in the tree. This warning surfaces | ||
| the situation; the targeted blocker (later) catches the regression case | ||
| automatically. Implemented as a warning so legitimately-empty binary | ||
| fixtures (rare but real -- e.g. `empty.xpi`, `0_sized_file`) can still |
There was a problem hiding this comment.
Reducing verbosity here would be good.
| Symptom of bug 1709608: diffs sourced from a landed commit have their | |
| binary payloads stripped by Phabricator, so a re-land using such a diff | |
| silently produces empty binary files in the tree. This warning surfaces | |
| the situation; the targeted blocker (later) catches the regression case | |
| automatically. Implemented as a warning so legitimately-empty binary | |
| fixtures (rare but real -- e.g. `empty.xpi`, `0_sized_file`) can still | |
| Diffs sourced from a landed commit have their | |
| binary payloads stripped by Phabricator, so a re-land using such a diff | |
| silently produces empty binary files in the tree. This warning surfaces | |
| the situation; at time of landing the check catches this case and warns about it. |
| the situation; the targeted blocker (later) catches the regression case | ||
| automatically. Implemented as a warning so legitimately-empty binary | ||
| fixtures (rare but real -- e.g. `empty.xpi`, `0_sized_file`) can still | ||
| be landed by acknowledging the warning. |
There was a problem hiding this comment.
| be landed by acknowledging the warning. |
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
creationMethodiscommit(the auto-generated diffPhabricator 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.querydiffsto detect the regressioncase (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
PreventEmptyBinaryCheckis 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
src/lando/utils/tests/test_landing_checks.pycover: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).
from a landed commit and confirm the warning appears.