← Back to PRs

#10709: fix(signal): guard JSON.parse against malformed RPC responses

by Yida-Dev open 2026-02-06 21:43 View on GitHub →
channel: signal stale
## 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