Settings
App-wide settings (FastPluggyConfig)
Stored in the database and editable in the admin UI at /admin/settings, in three sections.
Every field can also be set by an environment variable of the same name, uppercase; that value
wins over the saved one, so the admin shows the field locked with an environment badge.
| Section | Key | Default | Description |
|---|---|---|---|
| Branding | app_name |
"FastPluggy" |
Shown in the sidebar and in every browser tab title |
| Branding | app_subtitle |
"Admin Console" |
Line under the name in the sidebar |
| Branding | app_logo_icon |
"ti ti-puzzle" |
Tabler icon class of the brand |
| Admin & menu | admin_enabled |
True |
Mount the admin (System pages); read at start |
| Admin & menu | fp_admin_base_url |
"/admin" |
Admin URL prefix; read at start |
| Admin & menu | show_empty_menu_entries |
True |
Show sidebar parents with no visible children |
| Admin & menu | menu_promote_single_parent |
True |
A lone top-level menu parent shows its children in its place; a parent that is itself a page stays first; never applied to the admin menu |
| Admin & menu | include_in_schema_fp |
True |
Include FastPluggy routes in the OpenAPI schema |
| Admin & menu | hidden_advisories |
[] |
Advisory ids hidden on this deployment (Advisories) |
| Startup & performance | fp_plugins |
"*" |
Comma-separated entry-point plugin names, or "*" for all |
| Startup & performance | install_module_requirement_at_start |
True |
Install plugin requirements at start |
| Startup & performance | package_installer |
auto |
Installs plugin requirements: auto (pip, else uv), pip or uv |
| Startup & performance | debug |
False |
Show tracebacks on error pages |
| Startup & performance | static_cache_max_age |
86400 |
Seconds browsers keep the core's static files; a URL with the core's version (?v=0.4.x) is kept a year (immutable) |
| Storage | fp_data_dir |
"data" |
Where plugins keep their files, one folder per plugin (plugin_data_dir); relative to the app's working directory |
Env-only settings (not admin-UI-editable)
These four are read directly from the environment before the database is even
probed, so the app-level middleware they configure (SessionMiddleware,
GZipMiddleware) can be installed once at boot — required for the
degraded-mode self-heal (fast_pluggy#22) to work at all, since a middleware
can never be added again once the app has served its first request. They are
not FastPluggyConfig fields: they do not appear on /admin/settings and
cannot be stored in the database.
Their names are read whatever the case (session_secret_key works); the exact
uppercase name wins when both are set. A value that is empty or only whitespace
counts as not set.
Without SESSION_SECRET_KEY the app still starts, logs a warning, and signs
its sessions with a built-in default key that is public: anyone can forge a
session cookie. The core metric fp_core_session_key_default is 1 in that
case and 0 otherwise, so it can be alerted on.
| Env var | Default | Description |
|---|---|---|
SESSION_SECRET_KEY |
— | Required for session middleware |
SESSION_HTTPS_ONLY |
false |
Marks the fp_session cookie Secure. Required when the app is served over HTTPS and uses OIDC — authlib stores the OIDC state/nonce in this session and the IdP callback is a cross-site redirect, so Safari/iOS drops a non-Secure cookie and login fails with a state mismatch. |
FASTPLUGGY_GZIP_ENABLED |
true |
Enable response gzip compression |
FASTPLUGGY_GZIP_MINIMUM_SIZE |
500 |
Minimum response size (bytes) before compressing |
Where a plugin keeps its files
A plugin that writes files (uploads, caches, downloaded models) asks the core for its directory:
from fastpluggy.core.tools.fs_tools import plugin_data_dir
target = plugin_data_dir("my_plugin") / "uploads" # <fp_data_dir>/my_plugin/uploads
plugin_data_dir(module_name) returns <fp_data_dir>/<module_name> as an absolute path and
creates it when it is missing. fp_data_dir is the setting above: data by default, read from
the application's working directory, so a fresh checkout or a test run works without a /data
volume; a container sets FP_DATA_DIR=/data once for every plugin. The name is prefixed like
FP_PLUGINS: a DATA_DIR set for another program in the same environment is not read. A name
that is not a single folder name (.., a/b) raises ValueError.
- Pass the plugin's
module_name, so its files sit in a folder named like the plugin. - Call it where the path is used, not in a class body or as a settings default: it reads the core settings and creates a directory.
- A plugin setting that lets the operator choose another path stays useful: default it to empty
and fall back to
plugin_data_dir(...). - Changing
fp_data_dirmoves no file: move the folders yourself before restarting.
Per-plugin settings
Declare a Pydantic BaseSettings class and assign it to module_settings.
FastPluggy instantiates it at startup and persists values to the database.
from typing import Any
from pydantic_settings import BaseSettings
from fastpluggy.core.module_base import FastPluggyBaseModule
class MySettings(BaseSettings):
api_key: str = ""
max_items: int = 100
namespace: str = "my_plugin" # used as DB key prefix — keep unique
class Config:
env_prefix = "MY_PLUGIN_"
class MyPlugin(FastPluggyBaseModule):
module_settings: Any = MySettings # pass the class, not an instance
The settings form is auto-generated and available at /base_module/{module_name}/settings.
Each field is labelled with its Field(title=...) and shows its Field(description=...)
under the input; without a title, the label is the field name made readable
(max_items → "Max items"):
from pydantic import Field
class MySettings(BaseSettings):
max_items: int = Field(100, title="Items per page", description="Older items are paged.")
list and dict fields (list[str], List[int], dict) are stored as JSON in
fp_core_app_settings.value and loaded back as lists/dicts. The form shows a list as
['a', 'b']; that, JSON (["a", "b"]) and a comma-separated string (a, b) all save
correctly. Before 0.4.81 a list was stored as the form's text and failed validation on
load, so the plugin's settings no longer instantiated.
Passing an instance fails silently
PluginState checks isinstance(module_settings, type) before using it. Pass an
instance and it never raises and never calls it — it appends
"Settings should be a class, not instance." to the plugin's error, which surfaces
only as a warning triangle on the menu icon.
Omitting module_settings entirely is quieter still: the framework reports the plugin
as having no settings, while the configuration keeps working through env vars and
defaults. It reads as "this plugin has no configuration" rather than as a wiring bug,
so nothing looks broken.
Worth a structural test — and it must read the field on an instance, since
FastPluggyBaseModule is a Pydantic model.
Accessing settings at runtime
# From a lifecycle hook (fast_pluggy injected):
def on_load_complete(self, fast_pluggy):
manager = fast_pluggy.get_manager()
state = manager.modules.get(self.module_name)
cfg = state.settings # MySettings instance with DB-persisted values
# From a route handler:
@router.get("/my-route")
def my_route(fast_pluggy=Depends(get_fastpluggy)):
state = fast_pluggy.get_manager().modules.get("my_plugin")
cfg = state.settings
namespace field
The namespace field (if present) is used as the DB key prefix so multiple plugins
don't overwrite each other's settings. Set it to module_name and make it read-only in
the form:
How the admin shows a settings class
/admin/settings and the Settings tab of a plugin's page render the class with
SettingsFormWidget (fastpluggy.core.widgets). What it reads from each field:
| From the field | Shown as |
|---|---|
Field(title=...), Field(description=...) |
label and hint (default: the name, readable) |
bool |
a switch |
a name ending in _seconds, _minutes, _hours, _days, _ms, _bytes, or json_schema_extra={"unit": "..."} |
the unit after the input |
json_schema_extra={"group": "Broker"} |
one card per group, in order of appearance; fields without a group go under "General" |
SecretStr |
a secret badge; the value is never sent to the page |
| set by an environment variable | an environment badge, the input locked, and the variable named; a save leaves it alone |
| a value that differs from the default | a modified badge and Reset to default (not for secrets) |
A sticky bar under the form counts the unsaved changes. Saving still posts to the same URL as
before (POST /admin/base_module/<plugin>/settings).
from pydantic import Field
from pydantic_settings import BaseSettings
class WorkerSettings(BaseSettings):
broker_url: str = Field("memory://", title="Broker URL", json_schema_extra={"group": "Broker"})
poll_seconds: int = Field(5, description="How often idle workers look for work.",
json_schema_extra={"group": "Workers"})