Skip to content

Advisories

An advisory tells the operator that something should be looked at: a plugin that failed to load, a companion plugin that is missing, a deployment without authentication, a component that is unhealthy right now. The core and any plugin can report advisories; the admin collects them all in one place.

Reporting advisories from a plugin

Implement get_advisories() on the plugin class (the AdvisoryProvider protocol of fastpluggy.core.advisories). Nothing to declare: the core calls every loaded plugin that has it.

from typing import Annotated, Any

from fastpluggy.core.advisories import Advisory
from fastpluggy.core.module_base import FastPluggyBaseModule
from fastpluggy.core.tools.inspect_tools import InjectDependency


class MyPlugin(FastPluggyBaseModule):
    module_name: str = "my_plugin"
    module_settings: Any = MyPluginSettings
    advisory_ttl: float = 30  # optional: cache the answer for 30 s (default 0, no cache)
    settings_url: str | None = None

    def on_load_complete(self, fast_pluggy: Annotated["FastPluggy", InjectDependency]) -> None:
        self.settings_url = fast_pluggy.app.url_path_for("get_plugin_settings", plugin_name=self.module_name)

    def get_advisories(self) -> list[Advisory]:
        if not MyPluginSettings().api_key:
            return [Advisory(
                id="my_plugin.api_key.missing",
                severity="warning",
                category="config",
                title="No API key",
                detail="Requests to the provider fail until an API key is set.",
                action_label="Open settings",
                action_url=self.settings_url,
            )]
        return []
Field Meaning
id Stable id, <plugin>.<topic> with an optional :<key> (my_plugin.queue.full:emails). Letters, digits and _ . : -, 200 characters at most. Dismissing and hiding work on the exact id.
severity info, warning or critical.
title, detail What is wrong, and what it causes.
action_label, action_url Where to fix it. Build the URL with app.url_path_for(...): it needs no request.
category health, dependency, config, security, storage, upgrade or plugin. It only classifies.
dismissible False for a state that clears when its cause is fixed. Every health advisory is non-dismissible, whatever the plugin says.
banner Show it as a banner on every admin page. Keep it for what broke and blocks people.
about_plugins The plugins it concerns. Defaults to the reporting plugin.
source Filled by the core: the reporting plugin, or core.

health is for a running component that is unhealthy now (no worker online, a queue whose messages ran out of retries). Use another category for something to configure or install.

A missing optional_depends_on / integrates_with companion is reported by the core: do not report your own advisory for it.

Calls, timeouts and failures

The core calls the providers in parallel, under one deadline of 2 seconds. A provider that raises (an Advisory(...) with an unknown category raises in your code), or returns something else than a list, is replaced by one advisory core.provider.failed:<plugin>. In the list, an item that is not an Advisory, or that a later assignment made invalid, is set aside: the other advisories are shown, with one core.provider.failed:<plugin> saying which items were dropped and why. A provider that does not answer in time is replaced by core.provider.timeout:<plugin>. Its call keeps running in the background (a thread cannot be stopped): until it ends the provider is not called again, and its late answer serves the next collection. Keep get_advisories() fast, and set advisory_ttl when its checks are costly.

What the core reports

Id Severity When
core.plugin.load_failed:<plugin> critical An enabled plugin did not load. Not dismissible.
core.plugin.warnings:<plugin> warning A plugin loaded with warnings.
core.dependency.missing:<dependency> info An optional_depends_on or integrates_with companion is not loaded. One advisory per companion, listing every plugin that declares it.
core.dependency.version_mismatch:<plugin>.<dependency> warning The loaded companion's version does not match the declared constraint.
core.dependency.not_ordered:<plugin>.<dependency> warning An optional dependency lost its load order on a dependency cycle.
core.security.no_auth warning No authentication manager: the admin is open. Shown as a banner.
core.provider.failed:<plugin>, core.provider.timeout:<plugin> warning See above.

Where they show

Everything below loads after the page, from the JSON endpoint: a page never waits for the providers.

  • A banner on every admin page for the advisories with banner=True.
  • The plugin's page lists the advisories it reports and those about it.

GET {fp_admin_base_url}/advisories.json (admin only) answers {"advisories": [...], "counts": {"critical": n, "warning": n, "info": n}}, most serious first. counts counts the advisories still shown. Parameters:

Parameter Effect
plugin=<name> Only those reported by or about this plugin.
banner=true Only those shown as a banner.
include_dismissed=true Also those dismissed or hidden, flagged dismissed / hidden.

The warning and critical advisories are written to the log once, when the app starts, except the health ones: at boot no worker or beat has registered yet, so they would be false alarms.

Dismissing and hiding

  • From the admin: POST {fp_admin_base_url}/advisories/dismiss (and /advisories/restore) with {"id": "..."}. The ids are stored in the Advisories.dismissed_advisories app setting row, read on every request. Dismissing does not reload the app.
  • From the deployment's configuration: the hidden_advisories core setting, usually from the environment: HIDDEN_ADVISORIES='["core.security.no_auth"]'. For a deployment that runs without authentication on purpose, for example.

A non-dismissible advisory stays visible even when its id is dismissed or hidden; the core logs at startup that hidden_advisories lists it.