4.1 KiB
4.1 KiB
P0-005: Setup Flow Broken - Critical Onboarding Issue
Priority: P0 (Critical) Date Identified: 2025-12-13 Status: ACTIVE ISSUE - Breaking fresh installations
Problem Description
Fresh RedFlag installations show the setup UI but all API calls fail with HTTP 502 Bad Gateway, preventing server configuration. Users cannot:
- Generate signing keys (required for v0.2.x security)
- Configure database settings
- Create the initial admin user
- Complete server setup
Error Messages
XHR GET http://localhost:3000/api/health [HTTP/1.1 502 Bad Gateway]
XHR POST http://localhost:3000/api/setup/generate-keys [HTTP/1.1 502 Bad Gateway]
Root Cause Analysis
Issue 1: Auto-Created Admin User
Location: aggregator-server/cmd/server/main.go:170
// Always creates admin user on startup - prevents setup detection
userQueries.EnsureAdminUser(cfg.Admin.Username, cfg.Admin.Username+"@redflag.local", cfg.Admin.Password)
Problem:
- Admin user is created automatically from config before any UI is shown
- Setup page can't detect "no users exist" state
- User never gets redirected to proper setup flow
- Default credentials (if any) are unknown to user
Issue 2: 502 Bad Gateway Errors
Possible Causes:
- Database Not Ready: Setup endpoints may need database, but it's not initialized
- Missing Error Handling: Setup handlers might panic or return errors
- CORS/Port Issues: Frontend on :3000 calling backend on :8080 may be blocked
- Incomplete Configuration: Setup routes may depend on config that isn't loaded
Location: aggregator-server/cmd/server/main.go:73
router.POST("/api/setup/generate-keys", setupHandler.GenerateSigningKeys)
Issue 3: Setup vs Login Flow Confusion
Current Behavior:
- User builds and starts RedFlag
- Auto-created admin user exists (from .env or defaults)
- User sees setup page but doesn't know credentials
- API calls fail (502 errors)
- User stuck - can't login, can't configure
Expected Behavior:
- Detect if no admin users exist
- If no users: Force setup flow, create first admin
- If users exist: Show login page
- Setup should work even without full config
Reproduction Steps
-
Fresh clone/installation:
git clone <redflag-repo> cd RedFlag docker compose build docker compose up -
Navigate to http://localhost:8080 (or :3000 depending on config)
-
OBSERVED: Shows setup page
-
Click "Generate Keys" or try to configure
-
OBSERVED: 502 Bad Gateway errors in browser console
-
RESULT: Cannot complete setup, no way to login
Impact
- Critical: New users cannot install/configure RedFlag
- Security: Can't generate signing keys (breaks v0.2.x security)
- UX: Confusing flow (setup vs login)
- Onboarding: Complete blocker for adoption
Files to Investigate
aggregator-server/cmd/server/main.go:73- Setup route mountingaggregator-server/cmd/server/main.go:170- Auto-create admin useraggregator-server/internal/api/handlers/setup.go- Setup handlersaggregator-server/internal/services/signing.go- Key generation logicdocker-compose.yml- Port mapping issues
Quick Test
# Check if setup endpoint responds
curl -v http://localhost:8080/api/setup/generate-keys
# Expected: Either keys or error message
# Observed: 502 Bad Gateway
# Check server logs
docker-compose logs server | grep -A5 -B5 "generate-keys\|502\|error"
Definition of Done
- Setup page detects "no admin users" state correctly
- Setup API endpoints return meaningful responses (not 502)
- User can generate signing keys via setup UI
- User can configure database via setup UI
- First admin user created via setup (not auto-created)
- After setup: User redirected to login with known credentials
Temporary Workaround
Until fixed, users must:
- Check
.envfile for any default admin credentials - If none, check server startup logs for auto-created user
- Manually configure signing keys (if possible)
- Skip setup UI entirely
**This is not acceptable for production."