fix: duplicate startup warnings in admin panel#36641
fix: duplicate startup warnings in admin panel#36641silverwind merged 4 commits intogo-gitea:mainfrom
Conversation
LoadCommonSettings() is called twice during web server startup: once in InitWorkPathAndCommonConfig and again in serveInstalled. Since StartupProblems and configuredPaths were never cleared between calls, warnings accumulated and appeared duplicated in the admin panel. Clear both slices at the start of LoadCommonSettings() so only the final load's warnings are retained. Fixes go-gitea#36630
|
Comment written by Claude (AI assistant) I reviewed this PR. The analysis of the double-call problem is correct:
The fix is minimal and placed correctly. Clearing at the start of Two minor notes:
LGTM |
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Signed-off-by: silverwind <me@silverwind.io>
|
I think I can spend more time on this to have a better fix (avoid duplicate calls) I worry about the side effects of these duplicate calls, and I guess it is a problem caused by my code (introducing InitWorkPathAndCommonConfig to fix other problems) Will take a look when I get some time later. Thank you all. |
|
Yeah a root cause fix would be ideal, this is just a workaround. |
Fixes go-gitea#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>
Fixes #36630
Problem
StartupProblemswarnings (fromdeprecatedSettingand otherLogStartupProblemcalls) appear twice in the admin panel at/-/adminand/-/admin/self_check.LoadCommonSettings()is called twice during web server startup:cmd/main.go→InitWorkPathAndCommonConfig→LoadCommonSettings()cmd/web.go→serveInstalled→LoadCommonSettings()The second call re-initializes the config provider first (
InitCfgProvider), butStartupProblemsandconfiguredPathsare never cleared between loads, so every warning gets appended twice.Fix
Clear
StartupProblemsandconfiguredPathsat the start ofLoadCommonSettings()so only the final load's warnings are retained.This approach was chosen over clearing in
InitCfgProviderbecause:CfgProviderdirectly without callingInitCfgProviderScreenshots
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/settingtests pass[x] Manually verified in admin panel with deprecated
[oauth2].ENABLEsetting