fix(config): skip ConfigDB settings for modules that no longer exist

Ported from Akkoma af7c3fab9; the rescue is in the Ecto type load so
admin input is still validated.

Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
This commit is contained in:
Lain Soykaf 2026-10-31 13:43:59 +04:00
commit 88a9562a9b
No known key found for this signature in database
6 changed files with 74 additions and 0 deletions

View file

@ -48,6 +48,7 @@ defmodule Pleroma.Config.TransferTask do
settings =
(Repo.all(ConfigDB) ++ deleted_settings)
|> Enum.reject(&ConfigDB.static?/1)
|> Enum.reject(&(&1.group == :invalid_atom or &1.key == :invalid_atom))
|> Enum.map(&merge_with_default/1)
started_applications = Application.started_applications()

View file

@ -5,6 +5,8 @@
defmodule Pleroma.EctoType.Config.Atom do
use Ecto.Type
require Logger
def type, do: :atom
def cast(key) when is_atom(key) do
@ -17,8 +19,17 @@ defmodule Pleroma.EctoType.Config.Atom do
def cast(_), do: :error
# A key or group naming a module that no longer exists (e.g. a removed uploader)
# must not crash loading
def load(key) do
{:ok, Pleroma.ConfigDB.string_to_elixir_types(key)}
rescue
ArgumentError ->
Logger.warning(
"ConfigDB: unknown module #{key} in a setting key or group, the setting is not applied"
)
{:ok, :invalid_atom}
end
def dump(key) when is_atom(key), do: {:ok, inspect(key)}