Fix NullPointerException in AttachmentStore.retrieveAttachment upon receipt of voice messages#1989
Open
marshallaeon wants to merge 1 commit intoAsamK:masterfrom
Open
Fix NullPointerException in AttachmentStore.retrieveAttachment upon receipt of voice messages#1989marshallaeon wants to merge 1 commit intoAsamK:masterfrom
marshallaeon wants to merge 1 commit intoAsamK:masterfrom
Conversation
When getAttachment is called via JSON-RPC with a parameter name that
doesn't match the expected 'id' key (e.g. 'attachmentId'), the
JsonRpcNamespace returns null for ns.getString("id"). This null value
propagates to AttachmentStore.retrieveAttachment() which passes it to
new File(attachmentsPath, null), causing a NullPointerException.
Add an early null/empty check that throws a descriptive IOException
instead of an opaque NPE. This makes the error actionable for JSON-RPC
clients that send an incorrect parameter name.
Co-Authored-By: Oz <oz-agent@warp.dev>
Owner
|
Data should be validated as early as possible. Please add the null check in |
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.
Problem
The following happened when I sent a voice message from my Android phone to signal-cli via hermes-agent on my Mac.
AttachmentStore.retrieveAttachment()throws aNullPointerExceptionwhen called via JSON-RPC with a null attachment ID. This happens when a JSON-RPC client passes the attachment ID under a parameter name that doesn't match the expectedidkey (e.g.attachmentId). TheJsonRpcNamespacelookup returnsnull, which propagates through tonew File(attachmentsPath, null).Stack trace:
Fix
Add a null/empty guard in
retrieveAttachment()that throws a descriptiveIOExceptioninstead of an opaque NPE. This makes the error actionable for JSON-RPC clients that send an incorrect parameter name.