Skip to content

feat(doctor): warn when an enabled plugin isn't installed - #738

Open
dchaudhari7177 wants to merge 2 commits into
DobermanCore:mainfrom
dchaudhari7177:feat/719-doctor-plugin-check
Open

dchaudhari7177 wants to merge 2 commits into
DobermanCore:mainfrom
dchaudhari7177:feat/719-doctor-plugin-check

Conversation

@dchaudhari7177

Copy link
Copy Markdown
Contributor

Closes #719 (and its PostHog twin #731), including the stretch goal.

What changes

  • doctor gets a non-critical Plugins row, last in run_checks. It lands in the Health section, which is the default for unmapped rows. It compares plugin_config.enabled_plugins() with the entry-point names installed under every group in registry.ALL_GROUPS:
    • nothing enabled → [ ok ] Plugins: none enabled
    • an enabled name nothing provides → [warn] Plugins: enabled but not installed: <name>[, <name>…]
    • everything provided → [ ok ] Plugins: N enabled, all installed
  • Installed names come from a new doctor.installed_plugin_names(). It goes through registry._iter_entry_points only and reads .name, never .load(), so diagnosing a plugin can't import its code. This is the same approach plugins list already takes.
  • Stretch: doberman plugins enable <name> still enables the name and exits 0. When nothing installed provides it, it also prints warning: no installed package provides a plugin named '<name>'; it stays enabled but nothing loads until one is installed to stderr.

This doesn't touch #638 (the allowlist trusting a name under every entry-point group).

Tests

In tests/unit/test_cli_doctor.py, with DOBERMAN_PLUGINS_FILE pointed at tmp_path so the real config is never touched:

  • nothing enabled → the Plugins row is OK and non-critical;
  • no_such_plugin enabled → WARN enabled but not installed: no_such_plugin, and doberman doctor prints [warn] Plugins: enabled but not installed: no_such_plugin;
  • _iter_entry_points faked to yield an entry point whose load() raises: the installed name counts as installed and only the missing one is reported, so the check never loads anything;
  • plugins enable no_such_plugin warns, and enabling an installed name prints no warning.

On main these give 4 failed. On this branch test_cli_doctor.py + test_cli_plugins.py give 58 passed, 2 skipped. ruff check and format are clean, and lint-imports keeps 5 of 5 contracts.

AI assistance: I used an AI assistant while writing this change and the tests. I reviewed the diff and ran the tests above myself.

plugins enable only checks a name's format, so a typo or an uninstalled
package stays enabled with nothing saying so. Add a non-critical Plugins
row to doctor that compares the enabled names with the entry-point names
installed under every Doberman group, read through _iter_entry_points so
no plugin is ever loaded, and have plugins enable print the same warning
when nothing installed provides the name.

Closes DobermanCore#719

This branch has not been deployed

No deployments
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.

doctor: warn when an enabled plugin isn't installed

1 participant