diff options
Diffstat (limited to 'api/debug/health.php')
| -rw-r--r-- | api/debug/health.php | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/api/debug/health.php b/api/debug/health.php index 5a0048f..883588f 100644 --- a/api/debug/health.php +++ b/api/debug/health.php @@ -6,11 +6,24 @@ $sessions = load_json(SESSIONS_FILE); $lastError = !empty($errors) ? end($errors) : null; +// Self-referential rows mean the debug pipeline is counting itself: the failure mode that +// turned 33 real errors into 116,696 "occurrences" before 2026-10-23. Surface it instead of +// reporting a poisoned dataset as healthy. +$selfRef = 0; +$occurrences = 0; +foreach ($errors as $e) { + if (stripos($e['message'] ?? '', '/api/debug/') !== false) $selfRef++; + $occurrences += (int)($e['count'] ?? 1); +} + json_response([ 'success' => true, - 'status' => 'ok', + 'status' => $selfRef > 0 ? 'degraded' : 'ok', 'uptime' => filemtime(__FILE__) ? (time() - filemtime(__FILE__)) : 0, - 'total_errors' => count($errors), + 'total_errors' => $occurrences, + 'total_occurrences' => $occurrences, + 'unique_errors' => count($errors), + 'self_referential' => $selfRef, 'total_sessions' => count($sessions), 'errors_file_size_kb' => file_exists(ERRORS_FILE) ? round(filesize(ERRORS_FILE) / 1024, 1) : 0, 'sessions_file_size_kb' => file_exists(SESSIONS_FILE) ? round(filesize(SESSIONS_FILE) / 1024, 1) : 0, |