Skip to content

fix: duplicate startup warnings in admin panel#36641

Merged
silverwind merged 4 commits intogo-gitea:mainfrom
alessandroferra:fix/startup-warnings-duplicate
Feb 16, 2026
Merged

fix: duplicate startup warnings in admin panel#36641
silverwind merged 4 commits intogo-gitea:mainfrom
alessandroferra:fix/startup-warnings-duplicate

Conversation

@alessandroferra
Copy link
Copy Markdown
Contributor

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.goInitWorkPathAndCommonConfigLoadCommonSettings()
  2. Web server startup via cmd/web.goserveInstalledLoadCommonSettings()

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):
Screenshot From 2026-02-16 01-27-01

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

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
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 16, 2026
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Feb 16, 2026
@silverwind
Copy link
Copy Markdown
Member

Comment written by Claude (AI assistant)

I reviewed this PR. The analysis of the double-call problem is correct:

  1. cmd/main.goInitWorkPathAndCommonConfigLoadCommonSettings() (first call)
  2. cmd/web.goserveInstalledInitCfgProvider + LoadCommonSettings() (second call)

StartupProblems and configuredPaths accumulate across both calls, causing duplicates.

The fix is minimal and placed correctly. Clearing at the start of LoadCommonSettings rather than in InitCfgProvider is the right call, since LogStartupProblem callers outside LoadCommonSettings (e.g. services/webtheme/webtheme.go) run later during web startup and their warnings won't be lost.

Two minor notes:

  1. Using StartupProblems[:0] (reslice) instead of nil is fine — it reuses the underlying array on the next append, though for a startup-only slice the difference is negligible.

  2. For configuredPaths, the clear is mainly about cleanliness. Without it, re-adding the same (path, name) pairs from the second load wouldn't trigger false overlap warnings (since checkOverlappedPath checks targetName != name), but it could mask a real overlap if a path's logical owner changed between loads. Clearing makes the final state deterministic regardless.

LGTM

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Signed-off-by: silverwind <me@silverwind.io>
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 16, 2026
@wxiaoguang
Copy link
Copy Markdown
Contributor

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.

@wxiaoguang wxiaoguang marked this pull request as draft February 16, 2026 02:38
@wxiaoguang wxiaoguang self-assigned this Feb 16, 2026
@silverwind
Copy link
Copy Markdown
Member

Yeah a root cause fix would be ideal, this is just a workaround.

@wxiaoguang
Copy link
Copy Markdown
Contributor

wxiaoguang commented Feb 16, 2026

The duplicate LoadCommonSettings call is caused by Refactor to use urfave/cli/v2 (#25959) & Refactor path & config system #25330

I think we need to remove the LoadCommonSettings in serveInstalled. Will try

@github-actions github-actions bot added the modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin label Feb 16, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 16, 2026
@wxiaoguang wxiaoguang removed their assignment Feb 16, 2026
@wxiaoguang wxiaoguang marked this pull request as ready for review February 16, 2026 06:50
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 16, 2026
@silverwind silverwind enabled auto-merge (squash) February 16, 2026 07:45
@silverwind silverwind merged commit d9d66d0 into go-gitea:main Feb 16, 2026
24 checks passed
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 16, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 16, 2026
silverwind added a commit to Excellencedev/gitea that referenced this pull request Feb 17, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate startup warnings in admin panel

4 participants