Skip to content

fix: silence plugin warnings and folder creation when plugins disabled #4297

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

Merged
merged 3 commits into from
Jul 2, 2025

Conversation

deluan
Copy link
Member

@deluan deluan commented Jul 2, 2025

Description

This PR fixes issues with plugin-related warnings and directory creation that were impacting users when plugins are disabled. The changes ensure that plugin operations are only performed when plugins are actually enabled.

Key Changes:

  1. Silenced repeated "Plugin not found" warnings: Eliminated spam warnings for inactive Spotify/Last.fm agents when plugins are disabled
  2. Fixed plugin folder creation: Ensured the plugin folder is only created when plugins are enabled, preventing permission errors in restrictive environments
  3. Improved plugin system efficiency: Plugin loading operations are now completely bypassed when Plugins.Enabled = false

Related Issues

Fixes #4292 - This PR addresses the "permission denied" error when creating the plugins directory in environments where plugins are disabled.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Other (please describe):

Checklist

Please review and check all that apply:

  • My code follows the project's coding style
  • I have tested the changes locally
  • I have added or updated documentation as needed
  • I have added tests that prove my fix/feature works (or explain why not)
  • All existing and new tests pass

How to Test

  1. Set Plugins.Enabled = false in configuration
  2. Verify no "Plugin not found" warnings appear in logs for Spotify/Last.fm agents
  3. Verify the /data/plugins directory is not created when plugins are disabled
  4. Test in Docker environments with restrictive permissions to ensure no permission errors occur

Screenshots / Demos (if applicable)

Before: Logs filled with warnings like:

level=warning msg="Plugin not found" capability=MetadataAgent name=spotify

After: Clean logs with no plugin-related warnings when plugins are disabled and no builtin agents are configured.

Additional Notes

This fix is particularly important for Docker deployments and environments with restrictive file permissions, where the automatic creation of plugin directories can cause startup failures.

deluan added 3 commits July 2, 2025 12:44
…potify/Last.fm plugins

Navidrome was emitting a warning when the optional Spotify or
Last.fm agents weren’t enabled, filling the journal with entries like:

    level=warning msg="Plugin not found" capability=MetadataAgent name=spotify

Fixed by completely disable the plugin system when Plugins.Enabled = false.

Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
Signed-off-by: Deluan <deluan@navidrome.org>
@Copilot Copilot AI review requested due to automatic review settings July 2, 2025 16:55
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @deluan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses critical issues related to plugin management when plugins are disabled. The primary goal is to prevent unnecessary plugin-related warnings and errors, particularly concerning directory creation, and to improve overall system efficiency by completely bypassing plugin operations when they are not in use. This is achieved through conditional logic and a significant refactoring of the plugin manager to use an interface-based approach with a no-op implementation for disabled states.

Highlights

  • Silenced Plugin Warnings: Eliminated repetitive 'Plugin not found' warnings in logs for inactive Spotify/Last.fm agents when plugins are disabled, leading to cleaner log output.
  • Conditional Plugin Folder Creation: Modified the application startup logic to ensure the plugin folder is only created when plugins are explicitly enabled in the configuration. This prevents permission errors in restrictive environments where the directory might not be writable or needed.
  • Improved Plugin System Efficiency: Introduced a noopManager implementation for the plugin system. When Plugins.Enabled = false, the system now uses this no-op manager, completely bypassing plugin loading and related operations, which improves efficiency and reduces unnecessary resource usage.
  • Plugin Manager Refactoring: Refactored the plugins.Manager concrete type into a plugins.Manager interface and a plugins.managerImpl concrete implementation. This improves modularity, testability, and allows for the noopManager to be seamlessly integrated.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses the issues of plugin-related warnings and unnecessary folder creation when plugins are disabled. The introduction of the Manager interface and noopManager is a good design choice, improving efficiency and maintainability by completely bypassing plugin loading operations when they are not enabled. The refactoring from concrete *Manager types to *managerImpl and the Manager interface is well-executed across the codebase. Error handling in getPlugin has also been improved by returning errors instead of logging warnings, which is a positive change for correctness.

Copy link
Contributor

@Copilot Copilot AI left a comment

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 ensures plugin operations are skipped when plugins are disabled by introducing a Manager interface with a concrete managerImpl and a noopManager, and wrapping plugin folder creation in a feature flag.

  • Refactors plugin manager into an interface (Manager) and implementation (managerImpl), adding a noopManager when plugins are disabled.
  • Updates all plugin-related methods, adapters, and tests to use managerImpl receivers.
  • Wraps plugin directory creation in Load() so the folder is only created if Plugins.Enabled is true.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
plugins/runtime_test.go Updated test to use managerImpl instead of the old *Manager.
plugins/runtime.go Changed plugin runtime methods to receivers on managerImpl.
plugins/plugin_lifecycle_manager_test.go Updated test description and type to managerImpl.
plugins/manifest_permissions_test.go Switched test variable type from *Manager to *managerImpl.
plugins/manager_test.go Updated tests to declare mgr *managerImpl.
plugins/manager.go Introduced Manager interface, managerImpl, and noopManager.
plugins/host_websocket_test.go Switched manager *Manager to *managerImpl in test.
plugins/host_websocket.go Changed websocketService to hold *managerImpl.
plugins/host_scheduler_test.go Updated test to use *managerImpl.
plugins/host_scheduler.go Changed schedulerService to hold *managerImpl.
plugins/adapter_websocket_callback.go Adapter now expects *managerImpl instead of *Manager.
plugins/adapter_scrobbler.go Adapter now expects *managerImpl instead of *Manager.
plugins/adapter_scheduler_callback.go Adapter now expects *managerImpl instead of *Manager.
plugins/adapter_media_agent_test.go Switched test variable type from *Manager to *managerImpl.
plugins/adapter_media_agent.go Adapter now expects *managerImpl instead of *Manager.
conf/configuration.go Wrapped plugin folder creation in if Server.Plugins.Enabled.
cmd/wire_injectors.go Updated wire.Bind to reflect the new plugins.Manager interface.
cmd/wire_gen.go Mirrored injector changes for plugins.Manager bindings.
Comments suppressed due to low confidence (2)

plugins/manager.go:116

  • There's no test covering the case when Plugins.Enabled = false, which returns a noopManager. Consider adding a unit test to verify that disabling plugins yields a no-op manager with methods that do nothing.
func GetManager(ds model.DataStore, metrics metrics.Metrics) Manager {

plugins/plugin_lifecycle_manager_test.go:21

  • [nitpick] Test descriptions should focus on behavior rather than the concrete implementation name. Consider renaming this to Plugin Lifecycle Manager and using the Manager interface type in tests to avoid coupling to managerImpl.
	Describe("Plugin Lifecycle managerImpl", func() {

@deluan deluan merged commit a3d1a9d into master Jul 2, 2025
35 checks passed
@deluan deluan deleted the fix/disable-plugins branch July 2, 2025 17:18
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.

[Bug]: Not starting after upgrading from 0.56.1 to 0.57.0
1 participant