Repository navigation
fix(patch): reject binary file changes in npm patch commit - #10008
Open
manzoorwanijk wants to merge 1 commit into
Open
manzoorwanijk wants to merge 1 commit into
manzoorwanijk wants to merge 1 commit into
Conversation
Contributor
Author
|
CC: @reggi @martinrrm |
manzoorwanijk
marked this pull request as ready for review
September 21, 2026 08:13
manzoorwanijk
force-pushed
the
feat/patch-binary-files
branch
from
October 5, 2026 07:11
863d9b5 to
1a4a7cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Patches are unified text diffs, but
npm patch commitread every file as UTF-8, so an edited image, font or wasm file was written into the patch as a corrupted text diff instead of failing. This PR makescommitreject changed binary files withEPATCHBINARYand list them, so they can be reverted before committing.lib/utils/patch-diff.jstreats a file as binary when it contains a NUL byte or is not valid UTF-8. Unchanged binaries are ignored.patchedDependenciesentry is written.docs/lib/content/commands/npm-patch.md.Full binary patching is left out on purpose: patch-package, Yarn, pnpm and Bun all use text diffs only.
References
Follow-up to #9439