feat: handle symlinked plugin directories in Discover - #281
Open
crossoverJie wants to merge 3 commits into
Open
Conversation
- os.ReadDir reports symlinks as ModeSymlink, causing entry.IsDir() to return false and symlinked plugin directories to be silently skipped - Resolve symlinks via os.Stat before the IsDir check; broken symlinks produce a warning (matching existing skip-warning convention) - Add TestDiscover_symlinkedPluginDirectory and TestDiscover_brokenSymlink tests Signed-off-by: crossoverJie <crossoverJie@gmail.com>
crossoverJie
force-pushed
the
feature/symlinked-plugin-directories
branch
from
July 29, 2026 01:27
1e18805 to
4a6e410
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the CLI’s plugin discovery to correctly treat symlinked entries that resolve to directories as discoverable plugins, aligning behavior with how users often manage plugin directories via symlinks.
Changes:
- Resolve symlinked directory entries during
Discoverbyos.Stat-ing symlink paths and treating resolved directories as candidates. - Emit a warning and skip entries when symlink resolution fails (e.g., broken symlinks).
- Add tests covering discovery via symlinked plugin directories and broken-symlink warning behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
cli/internal/plugin/discover.go |
Adds symlink resolution so symlinked plugin directories are discovered and broken symlinks warn+skip. |
cli/internal/plugin/discover_test.go |
Adds coverage for symlinked plugin discovery and broken symlink handling. |
Comments suppressed due to low confidence (1)
cli/internal/plugin/discover_test.go:340
- This test will fail on platforms/environments where creating symlinks is not permitted (notably Windows without proper privileges). Skipping when os.Symlink fails keeps the test suite runnable while still exercising the behavior where symlinks are available.
symlinkPath := filepath.Join(pluginsDir, "broken-link")
if err := os.Symlink(brokenTarget, symlinkPath); err != nil {
t.Fatalf("could not create symlink: %v", err)
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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
Discovercurrently skips symlinked plugin directories becauseos.ReadDirentries for symlinks haveModeSymlinkrather thanModeDir, causingentry.IsDir()to returnfalse.This PR resolves symlinks via
os.Statso that plugin directoriesplaced behind a symlink are correctly discovered. Broken symlinks
produce a warning and are skipped (consistent with the existing
skip-warning behaviour for malformed plugins).
Related Issues
Checklist
Specification
core-spec/and follow the existing structureOntology
ontology/are consistent with spec changesConverters
converters/is updated to reflect spec or ontology changesValidation
validation/are updated if the spec changedDocumentation
docs/is updated to reflect any user-facing changesCONTRIBUTING.mdis updated if the contribution process changedExamples
examples/are added or updated for any new spec constructs or converter supportTests
go test ./.../ CI green)Compliance