#10709: fix(signal): guard JSON.parse against malformed RPC responses
channel: signal
stale
Cluster:
Cross-Platform Fixes
## Summary
- `signalRpcRequest` calls `JSON.parse` without try-catch — a non-JSON response (HTML error page, truncated body) causes an unhandled SyntaxError with no diagnostic context
- Wrap in try-catch that rethrows with HTTP status and a truncated body preview, matching the defensive pattern already used in `imessage/client.ts`
## Test plan
- [x] Verified error message includes status and body preview
- [x] All existing tests pass
Generated with [Claude Code](https://claude.com/claude-code)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Updates `signalRpcRequest` to wrap `JSON.parse` in a try/catch so malformed/non-JSON RPC responses don’t crash with an unhandled `SyntaxError`.
- On parse failure, throws a new error that includes the HTTP status and a truncated preview of the raw response body.
- Leaves existing empty-body and RPC-level error handling (`parsed.error`) intact within `src/signal/client.ts`.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- Change is localized to parsing of the Signal RPC response body and adds defensive error handling without altering the success path; the new error message is bounded via slicing and preserves existing behavior for empty bodies and RPC error objects.
- src/signal/client.ts
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#12984: fix(signal): fall back to JSON-RPC for health check on signal-cli 0...
by omair445 · 2026-02-10
75.7%
#23724: fix(security): sanitize RPC error messages in signal and imessage c...
by kevinWangSheng · 2026-02-22
74.4%
#19398: feat(signal): support native signal-cli JSON-RPC WebSocket
by jxstanford · 2026-02-17
73.1%
#4784: fix(imessage): handle non-JSON output from imsg CLI gracefully
by spiceoogway · 2026-01-30
71.8%
#2744: FIX(imessage): preserve signal info in RPC close handler
by sal-jim · 2026-01-27
71.5%
#11880: fix: guard decodeURIComponent against malformed percent-encoding in...
by Yida-Dev · 2026-02-08
69.3%
#23672: fix(resilience): guard JSON.parse of external process output with t...
by kevinWangSheng · 2026-02-22
68.8%
#7141: fix(telegram): unify network error detection to prevent poll crashes
by hclsys · 2026-02-02
67.4%
#6576: fix(signal): increase attachment fetch timeout to 60s
by rwarettg · 2026-02-01
66.8%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
66.3%