From 138081bd8beedf6c32914c865f4bf74cfdf282c4 Mon Sep 17 00:00:00 2001 From: mat Date: Thu, 5 Mar 2026 06:54:53 -0500 Subject: [PATCH] fix(ha): register IServerConfigurationManager in pre-startup DI for PostgreSQL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The NpgsqlDataSource singleton factory in AddJellyfinDbContext calls sp.GetRequiredService() to read pool settings. During ApplyStartupMigrationAsync, only a subset of services are registered in the startup service collection — IServerConfigurationManager was missing, causing a fatal DI resolution failure when DatabaseType=Jellyfin-PostgreSQL. Fix: register startupConfigurationManager as IServerConfigurationManager in the migrationStartupServiceProvider service collection. Also remove JELLYFIN_CONFIG_DIR=/config from Dockerfile.runtime ENV block. When configDir == dataDir, MakeSanityCheckOrThrow writes .jellyfin-config at the datadir root, then immediately throws because it expected .jellyfin-data. Removing the env var lets configDir default to $JELLYFIN_DATA_DIR/config. --- Dockerfile.runtime | 3 +-- Jellyfin.Server/Program.cs | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Dockerfile.runtime b/Dockerfile.runtime index 547ad3cb3d..76d6152d87 100644 --- a/Dockerfile.runtime +++ b/Dockerfile.runtime @@ -28,8 +28,7 @@ VOLUME ["/config", "/cache", "/media"] ENV JELLYFIN_DATA_DIR=/config \ JELLYFIN_CACHE_DIR=/cache \ - JELLYFIN_LOG_DIR=/config/log \ - JELLYFIN_CONFIG_DIR=/config + JELLYFIN_LOG_DIR=/config/log ENTRYPOINT ["./jellyfin", \ "--datadir", "/config", \ diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index 93f71fdc69..b38e3cc82d 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -285,6 +285,10 @@ namespace Jellyfin.Server .AddJellyfinDbContext(startupConfigurationManager, startupConfig) .AddSingleton(appPaths) .AddSingleton(appPaths) + // Required by NpgsqlDataSource factory in AddJellyfinDbContext when + // DatabaseType=Jellyfin-PostgreSQL — the factory resolves this from DI + // to read CustomProviderOptions and pool settings. + .AddSingleton(startupConfigurationManager) .RegisterStartupLogger(); migrationStartupServiceProvider.AddSingleton(migrationStartupServiceProvider);