feat: add safe RPC decoding/parsing in handleDeeplink and DeeplinkProtocolService#594
Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
feat: add safe RPC decoding/parsing in handleDeeplink and DeeplinkProtocolService#594devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
…tocolService - Add safeDecodeRpc helper that wraps base64 decode and JSON.parse in try-catch with descriptive errors - Use safeDecodeRpc in the new-connection branch (replaces raw decode/parse) - Wrap JSON.parse(clearRPC) in try-catch in the existing-connection branch with Logger.error and early return - Guard JSON.parse(decodedOriginatorInfo) in DeeplinkProtocolService.ts - Add test cases for invalid base64 and invalid JSON rpc inputs Co-Authored-By: Abhay Aggarwal <abhay.aggarwal@codeium.com>
Devin Review
|
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Adds defensive error handling around base64 decoding and JSON parsing of RPC messages in the SDK deeplink flow. Previously, malformed
rpcparameters (invalid base64 or invalid JSON) would throw unhandled exceptions. Now:safeDecodeRpchelper (new, inhandleDeeplink.ts): WrapsBuffer.from(rpc, 'base64')andJSON.parse(decoded)in separate try-catch blocks with descriptive error messages. Used in the new-connection branch.Existing-connection branch (
channelExists):JSON.parse(clearRPC)is now wrapped in a local try-catch that callsLogger.errorand returns early on malformed JSON.DeeplinkProtocolService.ts:JSON.parse(decodedOriginatorInfo)at line 439 is now guarded with a try-catch, logging the error and returning early.New test cases in
handleDeeplink.test.ts:handleConnectionMessageis not calledhandleConnectionMessageis not calledLogger.erroris called with descriptive message, early returnReview & Testing Checklist for Human
safeDecodeRpchelper correctly throws descriptive errors for both base64 decode failures and JSON parse failuresJSON.parse(clearRPC)logs viaLogger.errorand returns early without callinghandleConnectionMessageDeeplinkProtocolService.tsguard aroundJSON.parse(decodedOriginatorInfo)logs and returns earlyyarn test:unit -- app/core/SDKConnect/handlers/handleDeeplink.test.tsNotes
yarn installfails locally due to a missing GitHub archive (react-native-tcp), so tests could not be run in this session. CI should validate the tests.try-catchinhandleDeeplink(line 224) catches errors thrown bysafeDecodeRpcin the new-connection branch, so those are logged viaLogger.errorwith'Failed to connect to channel'.Link to Devin session: https://app.devin.ai/sessions/ccd663a8dc23460eaa8a6e02b2bd69d5
Requested by: @abhay-codeium