Skip to content

fix(watch): skip unreadable directories instead of failing the watch - #13992

Open
Endika wants to merge 2 commits into
docker:mainfrom
Endika:fix/watch-unreadable-directory
Open

fix(watch): skip unreadable directories instead of failing the watch#13992
Endika wants to merge 2 commits into
docker:mainfrom
Endika:fix/watch-unreadable-directory

Conversation

@Endika

@EndikaEndika commented Jul 31, 2026

Copy link
Copy Markdown

What I did

compose watch registers an inotify watch on every directory below the watched
path. A single directory the current user cannot read makes registration fail
with permission denied, and the whole watch fails to start — so nothing gets
watched at all.

Permission errors are now treated the way the surrounding code already treats
os.IsNotExist: log at debug level and filepath.SkipDir. Losing visibility
into one subtree should not cost the entire watch.

Includes a regression test in watcher_naive_test.go, which fails without the
change.

Related issue

closes#13750

domesticated-upset-golden-retriever-looking-out-window-missing-his-owner by https://www.magnific.com/

@Endika
Endika requested review from a team as code ownersJuly 31, 2026 17:45
@Endika
Endika requested review from glours and ndeloofJuly 31, 2026 17:45
@Endika
Endikaforce-pushed the fix/watch-unreadable-directory branch from eacf003 to e72f36aCompareAugust 1, 2026 07:47
@codecov

codecovBot commented Aug 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 9 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
pkg/watch/watcher_naive.go0.00%8 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Endika
Endikaforce-pushed the fix/watch-unreadable-directory branch 2 times, most recently from 7900d4b to 31835d3CompareAugust 3, 2026 17:27
Signed-off-by: Endika Iglesias <endika2@gmail.com>
CI runs the tests as root, where the unreadable-directory test is always
skipped. Extract the WalkDir callbacks and inject the watch registration
so a synthetic permission error can drive those branches instead.
Signed-off-by: Endika Iglesias <endika2@gmail.com>
@Endika
Endikaforce-pushed the fix/watch-unreadable-directory branch from 31835d3 to d5e70dfCompareAugust 5, 2026 07:52
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] watch tries to read ignored folders leading to permission denied

1 participant

@Endika