Files
slp-modular-cms/aidlc-docs/bugs/setup-page-after-failed-status-read/bug-fix.md
T
SluijsensandClaude Sonnet 5.5 ff94719455 Setup-pagina verschijnt niet meer als de setup-status niet te lezen is
De route-guard las elke fout (429, 500, 503, 404) als 'niet geinitialiseerd' en stuurde naar de
setup-pagina. Nu geen gok: bij een onleesbare status geen doorverwijzing. De statuslezing valt onder de
ruimere limiter in plaats van de strikte login-limiter (die 5 per minuut deelt met echte inlogpogingen).
De loginpagina meldt als het CMS uitgeschakeld of in onderhoud is.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-09 08:53:37 +01:00

42 lines
3.0 KiB
Markdown

# Bug Fix: the setup page appears when the setup status cannot be read
- **Slug**: setup-page-after-failed-status-read
- **Status**: Complete (pending deploy)
- **Issue**: None (reported by Bryan via "CMS & API", 2026-11-09; seen on ASF with the CMS switched off by the master, earlier on SlpSoftware)
- **Branch**: feature/identity-email-notifications
- **Started**: 2026-11-09
- **Documentation Language**: English
- **Conversation Language**: Dutch (user language)
## Report
After the master switched ASF to "not available", the admin showed the SETUP page ("create first account") instead of the dashboard or a notice. Expected: a failure to read the setup status must never show the setup page; a switched-off CMS shows that it is off.
## Root Cause
The admin's root route guard (`router.tsx`, `beforeLoad`) asks `GET /api/v1/Setup/status` on every page load. For any error other than a network failure it logged "assuming not initialized" and redirected to `/setup`. So a 429, 500, 503 or 404 answer, which says nothing about the system, sent people to the setup page of a system that already has its owner.
Two things made such errors likely: (1) since the optional setup token (U2) `GET Setup/status` was under the strict `login` rate limiter (5 a minute per client address, shared with real login attempts), so a few reloads used it up and the 429 that followed was read as "not set up"; (2) with the old availability gate a disabled CMS also answered 503 for much more than the API (fixed separately, 701091f).
I could not read the browser's actual response in Bryan's session, so the status code he got is not known; the guard turned every non-network error into the setup page, which is the defect whichever status it was.
**Confirmed with user**: relayed by "CMS & API".
## The Fix
- `router.tsx`: when the status cannot be read, the guard no longer guesses. A network failure still counts as "set up" (unchanged, so `/setup` leads to login); any other error means "unknown": no redirect either way, the normal pages deal with it.
- `SetupController.GetStatus` moves to the generous `refresh` limiter (20 a minute); the owner creation stays under the strict `login` one.
- Login page: when the CMS is disabled or in maintenance (open endpoint `/Availability/status`) a notice says so, with the message from the master and "only administrators can sign in right now"; the form stays (administrators pass the gate).
## Verification
**Path used**: Automated test framework. `setupGuard.test.tsx`: with the status answering 429, 500, 503, 404 or an empty 200 the login page is shown and the setup form is not; on a visitor already on `/setup` nothing moves; a readable `initialized: false` still leads to setup; the login notice for NotAvailable (with message) and Maintenance, nothing while Available. `SetupRateLimitTests`: status under `refresh`, owner creation under `login`.
**Before the fix**: 5 of the 6 error cases fail (the setup page appears); after: all pass. Frontend 390, Identity 141 green.
## Result
- **PR(s)**: None
- **Commit(s)**: see branch history
- **Completed**: 2026-11-09