mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-05-12 12:20:52 +00:00
Fix NullPointerException in AttachmentStore.retrieveAttachment
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>
This commit is contained in:
parent
c94da00212
commit
6832e21b12
@ -44,6 +44,9 @@ public class AttachmentStore {
|
||||
}
|
||||
|
||||
public StreamDetails retrieveAttachment(final String id) throws IOException {
|
||||
if (id == null || id.isEmpty()) {
|
||||
throw new IOException("Attachment ID must not be null or empty");
|
||||
}
|
||||
final var attachmentFile = new File(attachmentsPath, id);
|
||||
return Utils.createStreamDetailsFromFile(attachmentFile);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user