fix(resilience): guard JSON.parse of external process output with try-catch#23672
Closed
kevinWangSheng wants to merge 1 commit into
Closed
fix(resilience): guard JSON.parse of external process output with try-catch#23672kevinWangSheng wants to merge 1 commit into
kevinWangSheng wants to merge 1 commit into
Conversation
…-catch Co-Authored-By: Claude Opus 4.6 <[email protected]>
ed07c27 to
061cd69
Compare
3 tasks
|
This pull request has been automatically marked as stale due to inactivity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JSON.parsecalls parsing external process stdout (tailscale CLI) and disk-persisted queue entries lack try-catch protection, causing unhandled crashes on malformed inputSyntaxErrorthat crashes the gatewayJSON.parseinparseTailscaleStatusIPv4s()(bonjour-discovery.ts) andfailDelivery()(delivery-queue.ts), returning safe fallback values on parse failureChange Type
Scope
Security Impact
Compatibility / Migration
Risks and Mitigations
Greptile Summary
Added defensive
JSON.parseguards for external process output in two critical paths: Tailscale CLI output parsing (parseTailscaleStatusIPv4sin bonjour-discovery.ts:124-130) and disk-persisted delivery queue entries (failDeliveryin delivery-queue.ts:128-136). Both return safe fallback values (empty array/early return) on parse failure instead of crashing.parseTailscaleStatusIPv4s()now catches malformed/truncated JSON fromtailscale status --jsonand returns empty array, preventing gateway crashes during Tailnet discovery fallbackfailDelivery()catches corrupted queue JSON and exits silently, preventing crashes during delivery retry attemptsloadPendingDeliveries()already had similar protection (line 176), so this bringsfailDelivery()to parityConfidence Score: 5/5
loadPendingDeliveriesat line 176 for similar try-catch with graceful skip). Test coverage is comprehensive and verifies the exact failure scenarios. Both changes preserve happy-path behavior while adding critical crash prevention for external/disk data parsing.Last reviewed commit: 1bc2470
(5/5) You can turn off certain types of comments like style here!