fix: prevent ENOTDIR crash for non-component files in bundle directories @W-23924917@ - #1823
Open
WillieRuemmele wants to merge 2 commits into
Open
fix: prevent ENOTDIR crash for non-component files in bundle directories @W-23924917@#1823WillieRuemmele wants to merge 2 commits into
WillieRuemmele wants to merge 2 commits into
Conversation
…ype directories (W-23924917) When a non-component file (e.g., README.md, .DS_Store) sits directly inside a bundle type directory like lwc/, retrieve/deploy commands crash with ENOTDIR because the file path is passed to readDirectory(). Three complementary guards: - MixedContentSourceAdapter.getRootMetadataXmlPath: check isDirectory before calling tree.find() on the computed component root - BundleSourceAdapter.populate: skip files whose trimPathToContent resolves to a non-directory (i.e., files at the type directory level rather than inside a component folder) - NodeFSTreeContainer.readDirectory: return [] for non-directory paths instead of letting readdirSync throw ENOTDIR
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.
Summary
sf project retrieve start --metadataandsf project deploy start --metadatacrash withENOTDIRwhen a non-component file (e.g.,README.md,.DS_Store) sits directly inside a bundle type directory likelwc/, even if the file is in.forceignoreWhat changed
MixedContentSourceAdapter.getRootMetadataXmlPath— checksisDirectory(componentRoot)before callingtree.find(), preventing the direct crash site from being reachedBundleSourceAdapter.populate— when trigger is a file with no resolved component, checks whethertrimPathToContentresolves to a directory; if not (file is at type-dir level, not inside a component folder), returnsundefinedNodeFSTreeContainer.readDirectory— defense-in-depth: returns[]for non-directory paths instead of lettingreaddirSyncthrow ENOTDIRWhy this is safe
lwc/myCmp/helper.js),trimPathToContentreturns the component folder which IS a directory — guards pass, resolution continues normallyreadDirectoryguard matchesVirtualTreeContainer's existing behavior (which already threw on non-directory paths)Test plan
BundleSourceAdapter— non-component files (README.md, .DS_Store) returnundefined, valid components still resolveMetadataResolver.getComponentsFromPath— end-to-end: README.md inlwc/returns empty arrayNodeFSTreeContainer.readDirectory— returns[]for file paths