mirror of
https://github.com/go-gitea/gitea.git
synced 2026-02-19 04:57:41 +01:00
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): <img width="1429" height="195" alt="Screenshot From 2026-02-16 01-27-01" src="https://github.com/user-attachments/assets/d45313a2-f981-480b-9ffc-cbced7e40bb8" /> ## 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 <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>