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
..
actions.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin.go Fix mirror sync parser and fix mirror messages (#36504) 2026-02-11 00:16:05 +00:00
admin_auth.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin_auth_ldap.go Add an option to automatically verify SSH keys from LDAP (#35927) 2025-12-27 12:33:08 +00:00
admin_auth_ldap_test.go fix nilnil in onedev downloader (#36154) 2025-12-16 02:16:58 +00:00
admin_auth_oauth.go Refactor OpenIDConnect to support SSH/FullName sync (#34978) 2025-07-10 18:35:59 +00:00
admin_auth_oauth_test.go Refactor OpenIDConnect to support SSH/FullName sync (#34978) 2025-07-10 18:35:59 +00:00
admin_auth_smtp.go Fix incorrect cli default values and default command (#34765) 2025-06-18 23:25:11 +08:00
admin_auth_smtp_test.go Fix incorrect cli default values and default command (#34765) 2025-06-18 23:25:11 +08:00
admin_regenerate.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin_user.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin_user_change_password.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin_user_change_password_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
admin_user_create.go Address some CodeQL security concerns (#35572) 2025-10-04 01:21:26 +08:00
admin_user_create_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
admin_user_delete.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin_user_delete_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
admin_user_generate_access_token.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin_user_list.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
admin_user_must_change_password.go Address some CodeQL security concerns (#35572) 2025-10-04 01:21:26 +08:00
admin_user_must_change_password_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
cert.go Run `gopls modernize` on codebase (#34751) 2025-06-18 01:48:09 +00:00
cert_test.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
cmd.go Fix cli "Before" handling (#35797) 2025-10-31 18:12:03 +00:00
cmd_test.go Fix incorrect cli default values and default command (#34765) 2025-06-18 23:25:11 +08:00
config.go Intorduce "config edit-ini" sub command to help maintaining INI config file (#35735) 2025-10-25 10:54:55 +08:00
config_test.go Intorduce "config edit-ini" sub command to help maintaining INI config file (#35735) 2025-10-25 10:54:55 +08:00
docs.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
doctor.go Fix context usages (#35348) 2025-08-27 11:00:01 +00:00
doctor_convert.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
doctor_test.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
dump.go Don't store repo archives on `gitea dump` (#35467) 2025-09-12 16:11:24 +02:00
dump_repo.go Fix context usages (#35348) 2025-08-27 11:00:01 +00:00
embedded.go Replace gobwas/glob package (#35478) 2025-09-13 18:01:00 +00:00
generate.go Address some CodeQL security concerns (#35572) 2025-10-04 01:21:26 +08:00
hook.go Fix typos: unknow -> unknown, pktLineTypeUnknow -> pktLineTypeUnknown (#36419) 2026-01-22 01:17:06 +00:00
hook_test.go Fix some trivial problems (#36336) 2026-01-09 20:58:21 +02:00
keys.go Fix cli "Before" handling (#35797) 2025-10-31 18:12:03 +00:00
mailer.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
main.go chore: add comments for "api/healthz", clean up test env (#36481) 2026-01-30 10:23:38 +08:00
main_test.go chore: add comments for "api/healthz", clean up test env (#36481) 2026-01-30 10:23:38 +08:00
manager.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
manager_logging.go Fix incorrect cli default values and default command (#34765) 2025-06-18 23:25:11 +08:00
migrate.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
migrate_storage.go fix: spelling error in migrate-storage cmd utility (#36226) 2025-12-22 10:55:41 +00:00
migrate_storage_test.go Remove incorrect "db.DefaultContext" usages (#35366) 2025-08-28 03:52:43 +00:00
restore_repo.go Migrate to urfave v3 (#34510) 2025-06-10 12:35:12 +00:00
serv.go Fix clone mixed bug (#35810) 2025-11-02 00:52:59 -07:00
web.go fix: duplicate startup warnings in admin panel (#36641) 2026-02-16 08:13:04 +00:00
web_acme.go Enable addtional linters (#34085) 2025-04-01 10:14:01 +00:00
web_graceful.go Refactor some tests (#34580) 2025-06-03 01:26:19 +00:00
web_https.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00