-
Notifications
You must be signed in to change notification settings - Fork 5.8k
fix: handle recursive watcher ignore paths correctly #13756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ManManavadaria
wants to merge
5
commits into
docker:main
Choose a base branch
from
ManManavadaria:13750-watch-ignore-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a7349b1
fix: handle recursive watcher ignore paths correctly
ManManavadaria b62dbfd
fix: protect nested watch-root traversal from cross-trigger ignores a…
ManManavadaria 288a42e
Refactor watcher: per-path triggers and intersectPathMatcher
ManManavadaria a768660
Implement PathMatcher ignores in Darwin FSEvents watcher
ManManavadaria eee815e
fix(watch): scope ignore rules to each watch root
ManManavadaria File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[MEDIUM]
normalizeWatchRootsintersects child-trigger matchers into parent root — causes under-ignoring of pathsWhen building the normalized ignore matcher for a watch root,
normalizeWatchRootscollects matchers from ALL related trigger paths — including those where the trigger is a child of the root:NewIntersectMatcherrequires every matcher to agree before a path is ignored (logical AND). This means that if a child trigger path contributes its matcher to the parent root's intersection, a path must satisfy both the parent-root matcher and the unrelated child-root matcher to be ignored at the parent level.Concrete example with a realistic multi-service compose setup:
path: /project,ignore: [vendor/]→ignoresByWatchPath["/project"] = vendor_matcherpath: /project/pkg,ignore: [tmp/]→ignoresByWatchPath["/project/pkg"] = tmp_matcherFor root
/project,normalizeWatchRootscollects[vendor_matcher, tmp_matcher](because/project/pkgis a child of/project).normalizedIgnores["/project"] = intersect(vendor_matcher, tmp_matcher)Now
/project/vendor/x.go:vendor_matcher.Matches(...)→ true ✓tmp_matcher.Matches(...)→ false (it only matchestmp/)Expected:
/project/vendor/x.goshould be ignored per Service A's config, but it is not.Impact: Paths that should be ignored per one service's configuration are not ignored when another service with overlapping (but different) watch roots exists. This means the watcher emits spurious events for these paths and could still encounter permission errors on paths that were supposed to be skipped.
Suggested fix: Use
CompositePathMatcher(union/OR) when aggregating matchers from different trigger paths into a root's ignore matcher, rather thanintersectPathMatcher. A path should be ignored if any trigger for that root scope ignores it:Reserve
intersectPathMatcherfor its intended purpose: combining matchers for the same trigger path (where a file should only be ignored if every watch rule for that exact path agrees).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initially I thought of using
CompositeMatcherin normalizeWatchRoots. but in this case it would work incorrectlyService A:
path: /project,ignore: [repo/]Service B:
path: /project/repo/pkg,ignore: [tmp/]In this example, the normalized root would be
/project. If we use aCompositeMatcher, then/repowould be ignored, which means/project/repo/pkgwould not be watched. That’s why I usedIntersectMatcherinstead.