From eff96c5721aab4eac56f3cc16cb1f48c802bd068 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 16 Jul 2026 05:00:26 +0000 Subject: [PATCH] bug: fix 500 on Post create/edit from null-deref in DetailPostDto.TagNames ASP.NET Core's validation visitor evaluates the computed TagNames getter on the posted DTO, but Tags is [ScaffoldColumn(false)], never model-bound, and null at that point -> ArgumentNullException before the controller runs. Make the display-only getter null-safe (affects sync + async DTOs). Co-Authored-By: Parker Duff --- ServiceLayer/PostServices/DetailPostDto.cs | 2 +- ServiceLayer/PostServices/DetailPostDtoAsync.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ServiceLayer/PostServices/DetailPostDto.cs b/ServiceLayer/PostServices/DetailPostDto.cs index 005de7b..1f6d160 100644 --- a/ServiceLayer/PostServices/DetailPostDto.cs +++ b/ServiceLayer/PostServices/DetailPostDto.cs @@ -93,7 +93,7 @@ public class DetailPostDto : ILinkToEntity /// public DateTime LastUpdatedUtc { get { return DateTime.SpecifyKind(LastUpdated, DateTimeKind.Utc); } } - public string TagNames { get { return string.Join(", ", Tags.Select(x => x.Name)); } } + public string TagNames { get { return Tags == null ? string.Empty : string.Join(", ", Tags.Select(x => x.Name)); } } //ctor public DetailPostDto() diff --git a/ServiceLayer/PostServices/DetailPostDtoAsync.cs b/ServiceLayer/PostServices/DetailPostDtoAsync.cs index c133b32..bf20784 100644 --- a/ServiceLayer/PostServices/DetailPostDtoAsync.cs +++ b/ServiceLayer/PostServices/DetailPostDtoAsync.cs @@ -92,7 +92,7 @@ public class DetailPostDtoAsync : ILinkToEntity /// public DateTime LastUpdatedUtc { get { return DateTime.SpecifyKind(LastUpdated, DateTimeKind.Utc); } } - public string TagNames { get { return string.Join(", ", Tags.Select(x => x.Name)); } } + public string TagNames { get { return Tags == null ? string.Empty : string.Join(", ", Tags.Select(x => x.Name)); } } //ctor public DetailPostDtoAsync()