From 58164be640d2e8b326d6b2869db5924e89053fa6 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 20 Jan 2026 13:57:43 +0100 Subject: [PATCH] Handle missing PsPdfKitAnnotation with blank JSON Refactored DocStatusHandler to assign a blank JSON object ("{}") to the Value property when PsPdfKitAnnotation is not present or not of the expected type, preventing potential runtime errors. --- .../Notifications/DocSigned/Handlers/DocStatusHandler.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/DocStatusHandler.cs b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/DocStatusHandler.cs index ca264295..adae66cf 100644 --- a/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/DocStatusHandler.cs +++ b/EnvelopeGenerator.Application/Common/Notifications/DocSigned/Handlers/DocStatusHandler.cs @@ -10,6 +10,8 @@ namespace EnvelopeGenerator.Application.Common.Notifications.DocSigned.Handlers; /// public class DocStatusHandler : INotificationHandler { + private const string BlankAnnotationJson = "{}"; + private readonly ISender _sender; /// @@ -33,7 +35,9 @@ public class DocStatusHandler : INotificationHandler { Envelope = new() { Id = notification.EnvelopeId }, Receiver = new() { Id = notification.ReceiverId}, - Value = JsonSerializer.Serialize(notification.PsPdfKitAnnotation.Instant, Format.Json.ForAnnotations) + Value = notification.PsPdfKitAnnotation is PsPdfKitAnnotation annot + ? JsonSerializer.Serialize(annot.Instant, Format.Json.ForAnnotations) + : BlankAnnotationJson }, cancel); } } \ No newline at end of file