From d9d66d04d0dcd737592dbdaa5369210d47d188fe Mon Sep 17 00:00:00 2001
From: Alessandro Ferrari <48022579+alessandroferra@users.noreply.github.com>
Date: Mon, 16 Feb 2026 09:13:04 +0100
Subject: [PATCH] fix: duplicate startup warnings in admin panel (#36641)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes #36630
## Problem
`StartupProblems` warnings (from `deprecatedSetting` and other
`LogStartupProblem` calls) appear twice in the admin panel at `/-/admin`
and `/-/admin/self_check`.
`LoadCommonSettings()` is called twice during web server startup:
1. Early init via `cmd/main.go` → `InitWorkPathAndCommonConfig` →
`LoadCommonSettings()`
2. Web server startup via `cmd/web.go` → `serveInstalled` →
`LoadCommonSettings()`
The second call re-initializes the config provider first
(`InitCfgProvider`), but `StartupProblems` and `configuredPaths` are
never cleared between loads, so every warning gets appended twice.
## Fix
Clear `StartupProblems` and `configuredPaths` at the start of
`LoadCommonSettings()` so only the final load's warnings are retained.
This approach was chosen over clearing in `InitCfgProvider` because:
- Warnings are produced during settings load, not provider init
- Some callers set `CfgProvider` directly without calling
`InitCfgProvider`
- It avoids coupling correctness to a specific call ordering
## Screenshots
**Result** (single warning as expected):
## testing
[x] Added `TestLoadCommonSettingsClearsStartupProblems` — verifies no
duplicate messages after consecutive loads
[x] Added `TestLoadCommonSettingsClearsConfiguredPaths` — verifies path
overlap map is identical after consecutive loads
[x] All existing `modules/setting` tests pass
[x] Manually verified in admin panel with deprecated `[oauth2].ENABLE`
setting
---------
Signed-off-by: silverwind
Co-authored-by: silverwind
Co-authored-by: wxiaoguang
---
cmd/web.go | 2 --
1 file changed, 2 deletions(-)
diff --git a/cmd/web.go b/cmd/web.go
index 61cfb87130..5000e780c5 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -163,8 +163,6 @@ func serveInstall(cmd *cli.Command) error {
}
func serveInstalled(c *cli.Command) error {
- setting.InitCfgProvider(setting.CustomConf)
- setting.LoadCommonSettings()
setting.MustInstalled()
showWebStartupMessage("Prepare to run web server")