Repository navigation
fs: support Buffer paths in cp() and cpSync() - #65713
Open
HuzaifaAbdulRehman wants to merge 1 commit into
Open
HuzaifaAbdulRehman wants to merge 1 commit into
HuzaifaAbdulRehman wants to merge 1 commit into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65713 +/- ##
==========================================
- Coverage 90.59% 90.58% -0.01%
==========================================
Files 802 802
Lines 286570 286613 +43
Branches 55358 55369 +11
==========================================
+ Hits 259613 259631 +18
- Misses 17065 17081 +16
- Partials 9892 9901 +9
🚀 New features to boost your workflow:
|
HuzaifaAbdulRehman
force-pushed
the
fix/58634-cp-buffer-paths-filter
branch
2 times, most recently
from
September 2, 2026 09:17
258a798 to
004d3c3
Compare
Author
|
@jasnell, could you take a look when you have a chance? This PR also still needs a full CI run. |
This comment was marked as resolved.
This comment was marked as resolved.
Buffer paths must preserve byte names during recursion. Fixes: nodejs#58634 Assisted-by: Claude Code, Codex Signed-off-by: Huzaifa Abdul Rehman <huzaifarehman897@gmail.com>
HuzaifaAbdulRehman
force-pushed
the
fix/58634-cp-buffer-paths-filter
branch
from
November 29, 2026 16:07
004d3c3 to
97e21f7
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.
What breaks
fs.cpSync()with afilter, andfs.promises.cp(), throwERR_INVALID_ARG_TYPEwhensrcordestis aBuffer, though Buffer paths are accepted elsewhere infs(they address non-UTF-8 byte file names on POSIX).Root cause
The recursive walk builds child paths with
path.join(src, name), and the async path also runspath.resolve()/path.dirname()in its structural checks. All reject a Buffer.cpSyncwithout a filter avoids it (that branch runs in C++);cp.promiseshits it inisSrcSubdirbefore copying.The change
joinPathjoins entries onto Buffer paths by concatenating bytes, andcopyDirreads entries withencoding: 'buffer'for Buffer sources, so non-UTF-8 names survive rather than being mangled.toPathStringdecodes to a string only for the subdirectory and parent-directory checks; the copy keeps the Buffers.String paths over a non-UTF-8-named entry stay unchanged (a string cannot carry those bytes) and remain a known issue, nearer #58869.
Tests
Promotes the two #58634 known-issue tests into
test/parallel/and adds a Linux-only byte-fidelity test (a Shift-JIS file name copied intact through Buffer paths).Fixes: #58634