fix: return 503 when Meshtastic node is not connected (traceroute and mesh requests)#3597
Conversation
Traceroute (and position/nodeinfo/neighborinfo/telemetry) requests threw a generic 500 when the node wasn't connected, hiding the real cause from the UI. Now the catch block detects "Not connected" errors and returns 503 with an actionable message, matching the pattern already used in src/server/routes/v1/messages.ts. Fixes #3596 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C3W1sLHSwNrrUzDQutFnyy
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @Yeraze's task —— View job PR Review
SummaryThis is a clean, focused fix that correctly propagates connection errors as 503 responses. The implementation is solid. A few observations: Strengths
Minor Observations1. Slight response shape inconsistency with
{ "success": false, "error": "Service Unavailable", "message": "Not connected to Meshtastic node" }This PR returns a simpler shape across all five handlers: { "error": "Not connected to Meshtastic node" }This inconsistency is minor, but if the frontend checks 2. Test coverage gap: 3 of 5 handlers lack 503 tests Tests were added for 3. String matching is fragile The VerdictThe fix is correct and consistent with the existing codebase pattern. The two minor gaps (response shape inconsistency and incomplete test coverage) are non-blocking but worth addressing if polish is desired before merging. |
…lers
Addresses review feedback on the "503 when not connected" fix:
1. The five mesh-request handlers now return the same 503 body shape as
v1/messages.ts — { success: false, error: 'Service Unavailable',
message: 'Not connected to Meshtastic node' } — instead of a bare
{ error: '...' }. The api.ts callers (sendTraceroute/requestPosition)
read `error.message || error.error` so the specific reason still
surfaces (they previously read only `.error`, which would otherwise
have regressed to showing "Service Unavailable").
2. Add 503 regression tests for the three previously-uncovered handlers
(/nodeinfo/request, /telemetry/request, and /neighborinfo/request —
the latter failing after the eligibility/rate-limit checks).
Also adds the missing CHANGELOG entry for #3596.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SVGxkuD4Fwa2JGVim8ZeVj
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @Yeraze's task —— View job PR Review
SummaryThis is a clean, focused fix. The implementation is correct and complete. Here's the full review: Code Quality —
|
Summary
Fixes #3596
When the Meshtastic node is disconnected,
sendTraceroute(and all othermeshRequestRouteshandlers) threwError: Not connected to Meshtastic nodewhich was caught and blindly re-emitted as a generic500 { error: 'Failed to send traceroute' }. The frontend had no way to tell the user what actually went wrong."Not connected"errors in the catch block of all five route handlers (/traceroute,/position/request,/nodeinfo/request,/neighborinfo/request,/telemetry/request) and return 503 with the message"Not connected to Meshtastic node"— matching the pattern already used insrc/server/routes/v1/messages.ts.Test plan
meshRequestRoutes.test.tsstill pass🤖 Generated with Claude Code
https://claude.ai/code/session_01C3W1sLHSwNrrUzDQutFnyy
Generated by Claude Code