Files
Gitea/cmd
Alessandro Ferrari d9d66d04d0 fix: duplicate startup warnings in admin panel (#36641)
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>
2026-02-16 08:13:04 +00:00
..
2025-06-10 12:35:12 +00:00
2025-06-10 12:35:12 +00:00
2025-06-10 12:35:12 +00:00
2025-06-10 12:35:12 +00:00
2025-10-31 18:12:03 +00:00
2025-06-10 12:35:12 +00:00
2025-06-10 12:35:12 +00:00
2025-08-27 11:00:01 +00:00
2025-08-27 11:00:01 +00:00
2025-10-31 18:12:03 +00:00
2025-06-10 12:35:12 +00:00
2025-06-10 12:35:12 +00:00
2025-06-10 12:35:12 +00:00
2025-06-10 12:35:12 +00:00
2025-11-02 00:52:59 -07:00
2025-04-01 10:14:01 +00:00
2025-06-03 01:26:19 +00:00