Skip to content

feat: handle symlinked plugin directories in Discover - #281

Open
crossoverJie wants to merge 3 commits into
apache:mainfrom
crossoverJie:feature/symlinked-plugin-directories
Open

feat: handle symlinked plugin directories in Discover#281
crossoverJie wants to merge 3 commits into
apache:mainfrom
crossoverJie:feature/symlinked-plugin-directories

Conversation

@crossoverJie

Copy link
Copy Markdown
Member

Summary

Discover currently skips symlinked plugin directories because
os.ReadDir entries for symlinks have ModeSymlink rather than
ModeDir, causing entry.IsDir() to return false.

This PR resolves symlinks via os.Stat so that plugin directories
placed 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

  • Spec changes are included in core-spec/ and follow the existing structure
  • Spec changes have been discussed on the mailing list or in a linked issue
  • Breaking changes to the spec are clearly called out in the summary

Ontology

  • Ontology changes in ontology/ are consistent with spec changes
  • New or modified terms are defined and documented

Converters

  • Converter logic in converters/ is updated to reflect spec or ontology changes
  • New converters include tests under the converter's test directory

Validation

  • Validation rules in validation/ are updated if the spec changed
  • New validation cases are covered by tests

Documentation

  • docs/ is updated to reflect any user-facing changes
  • New features or behaviors are documented with examples where appropriate
  • CONTRIBUTING.md is updated if the contribution process changed

Examples

  • examples/ are added or updated for any new spec constructs or converter support

Tests

  • All existing tests pass (go test ./... / CI green)
  • New functionality is covered by tests

Compliance

  • ASF license headers are present on all new source files
  • No third-party dependencies are added without PMC/IPMC approval

Copilot AI review requested due to automatic review settings July 29, 2026 01:25
- 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
crossoverJie force-pushed the feature/symlinked-plugin-directories branch from 1e18805 to 4a6e410 Compare July 29, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Discover by os.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.

Comment thread cli/internal/plugin/discover_test.go
crossoverJie and others added 2 commits July 29, 2026 09:32
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to 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.

2 participants