fix(sync): exclude symlinked files from discovery results#2849
Merged
tusharmath merged 2 commits intomainfrom Apr 5, 2026
Merged
fix(sync): exclude symlinked files from discovery results#2849tusharmath merged 2 commits intomainfrom
tusharmath merged 2 commits intomainfrom
Conversation
This was referenced Apr 6, 2026
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
Exclude symlinked files from file discovery results in both the filesystem walker and the
filter_and_resolvepipeline, ensuring only real files are ever indexed or synced.Context
Both the
Walker(used for general directory traversal) andfilter_and_resolve(used for the sync pipeline via git or walker-based discovery) could previously surface symlinks as indexable files. This caused problems because symlinks may point to files outside the workspace, create circular paths, or be dangling (pointing to non-existent targets) — all of which are invalid inputs for the indexing and sync pipeline.Changes
forge_walker: Added a symlink guard inget_blocking()usingentry.path_is_symlink()from theignorecrate'sDirEntry, which correctly identifies symlinks without following them. Both regular and dangling symlinks are filtered out before any further processing.forge_services/fd: Added anis_symlink()helper that usessymlink_metadata()(which does not follow the link) and wired it intofilter_and_resolve()as an early filter before the extension check. This covers symlinks surfaced by git-based discovery as well as walker-based discovery.Key Implementation Details
path_is_symlink()in the walker relies on theignore::DirEntryAPI, which reads the symlink bit from the directory entry without stat-following — making it safe and efficient even for dangling symlinks.symlink_metadata()infd.rsis the POSIX equivalent (lstat); it returns the metadata of the link itself rather than its target, so dangling links are still correctly identified and excluded.filter_and_resolve, before the extension allow-list filter, so no unnecessary filesystem work is done on links.Testing
Tests were added for all symlink scenarios in both crates:
forge_walker:forge_services:Or run all tests at once:
cargo insta test --accept