Fix null reference issue in DocumentController

Added a null-conditional operator (`?.`) to safely access the
`ByteData` property of the `senderDoc` object, preventing a
potential `NullReferenceException` when `senderDoc` is null.
This commit is contained in:
2026-10-01 12:14:46 +02:00
parent 819bdcfcfb
commit e9c0ec139a

View File

@@ -37,7 +37,7 @@ public class DocumentController(IMediator mediator, IAuthorizationService authSe
return BadRequest("Missing document query."); return BadRequest("Missing document query.");
var senderDoc = await mediator.Send(query, cancel); var senderDoc = await mediator.Send(query, cancel);
return senderDoc.ByteData is byte[] senderDocByte return senderDoc?.ByteData is byte[] senderDocByte
? File(senderDocByte, "application/octet-stream") ? File(senderDocByte, "application/octet-stream")
: NotFound("Document is empty."); : NotFound("Document is empty.");
} }