fix: Treat HTTP 429 as OK in health check

429 (Too Many Requests) means the endpoint is working correctly
and is protected by rate limiting - this is expected behavior
for /register endpoint.

- Add 429 to acceptable status codes (200, 302, 304, 429)
- Update legend to explain 429 means protection is working
- Apply to all health check endpoints

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-01-15 04:15:39 +01:00
parent 3acbc53b87
commit 90da6b9c64
2 changed files with 10 additions and 3 deletions

9
app.py
View File

@ -826,8 +826,9 @@ def health_full():
status = response.status_code
# 200 = OK, 302 = redirect (np. do logowania) = OK
# 429 = rate limited (endpoint działa, tylko ograniczony)
# 500 = błąd serwera, 404 = nie znaleziono
if status in (200, 302, 304):
if status in (200, 302, 304, 429):
results.append({
'endpoint': path,
'name': name,
@ -8144,7 +8145,9 @@ def admin_health():
response_time = (datetime.now() - start_time).total_seconds() * 1000 # ms
# Determine status
if status_code in (200, 302, 304):
# 429 = rate limited (endpoint works, just protected)
# 403 = forbidden (endpoint works, requires auth)
if status_code in (200, 302, 304, 429):
status = 'ok'
elif status_code == 404:
status = 'not_found'
@ -8227,7 +8230,7 @@ def api_admin_health():
try:
response = client.get(path, follow_redirects=False)
status_code = response.status_code
ok = status_code in (200, 302, 304)
ok = status_code in (200, 302, 304, 429) # 429 = rate limited, endpoint works
results.append({'path': path, 'name': name, 'status': status_code, 'ok': ok})
except Exception as e:
results.append({'path': path, 'name': name, 'status': 500, 'ok': False, 'error': str(e)[:50]})

View File

@ -456,6 +456,10 @@
<span class="endpoint-code ok">302</span>
<span>Redirect - przekierowanie (np. do logowania)</span>
</div>
<div style="display: flex; align-items: center; gap: var(--spacing-xs);">
<span class="endpoint-code ok">429</span>
<span>Rate Limited - ochrona przed botami (działa!)</span>
</div>
<div style="display: flex; align-items: center; gap: var(--spacing-xs);">
<span class="endpoint-code warning">403</span>
<span>Forbidden - brak uprawnień</span>