#10123: fix: guard deep health probe against unreachable gateway (#9091)
commands
stale
size: S
trusted-contributor
Cluster:
Gateway and TLS Enhancements
Root cause: `status --deep` health probe had no `gatewayReachable` guard and no error handling, causing crashes when gateway is unreachable.
Fix: Add `gatewayReachable` guard (matching `status-all.ts` pattern) and capture errors via `.catch((err) => ({ error: String(err) }))` for display in the Health section.
Test: Two independent tests verify (1) guard prevents health probe when gateway unreachable, (2) errors are captured and displayed when probe fails.
Fixes #17106
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Added `gatewayReachable` guard to prevent health probe when gateway is unreachable, and wrapped the probe in `.catch()` to capture errors instead of crashing. This matches the established pattern from `status-all.ts:192-198` where health probes are guarded and errors are caught.
- Fixed crash when `status --deep` runs with unreachable gateway
- Added type guard `isHealthError()` to distinguish error results from valid `HealthSummary` objects
- Added comprehensive tests covering both guard and error-capture scenarios
- Updated CHANGELOG.md with fix description
Minor issue: type guard function is placed between import statements (should be moved after all imports).
<h3>Confidence Score: 4/5</h3>
- Safe to merge after fixing import placement
- The fix correctly implements the guard pattern from `status-all.ts`, adds proper error handling, and includes thorough tests. One syntax issue (type guard between imports) needs fixing, but the core logic is sound.
- Fix `src/commands/status.command.ts:38-42` to move type guard after imports
<sub>Last reviewed commit: 0a0dd16</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22716: fix: gateway status probe uses wss:// when TLS enabled; accept self...
by Fratua · 2026-02-21
77.7%
#9879: Improve gateway probe diagnostics for slow channels
by wrgrant · 2026-02-05
75.1%
#19437: Gateway: respect custom bind host for local health/RPC target resol...
by frudas24 · 2026-02-17
74.5%
#23672: fix(resilience): guard JSON.parse of external process output with t...
by kevinWangSheng · 2026-02-22
74.4%
#4653: fix(gateway): improve crash resilience for mDNS and network errors
by AyedAlmudarra · 2026-01-30
74.2%
#6039: fix: improve type safety in gateway registration
by Bharadwajreddy1406 · 2026-02-01
74.1%
#22327: fix(doctor): use gateway health status for memory search key check
by therk · 2026-02-21
73.8%
#20355: fix(gateway): enforce commands.restart guard for config.apply and c...
by Clawborn · 2026-02-18
73.2%
#13960: fix(ui): preserve structured config validation error details
by constansino · 2026-02-11
72.6%
#12870: fix: recover from telegram fetch errors (issue #12835)
by ambicuity · 2026-02-09
72.6%