bug: fix 500 on Post create/edit (null-deref in DetailPostDto.TagNames) - #28
Open
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…Names 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 <pwjduff@gmail.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Author
✅ Re-test: Post create/edit 500 is fixed (via Devin session)Checked out
Re-test recording: Sync Post created (was a 500 before): |
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.
Summary
Fixes an unhandled HTTP 500 when saving a Post via
/Posts/Create,/Posts/Edit,/PostsAsync/Create,/PostsAsync/Editon the migrated .NET 10 app. Found during end-to-end testing of the merged web-migration (PR #25).Root cause — behavior difference between MVC5 and ASP.NET Core model validation. ASP.NET Core's
ValidationVisitorwalks the posted model graph and evaluates computed getters.DetailPostDto/DetailPostDtoAsyncexpose a display-only:but
Tagsis[ScaffoldColumn(false)], is never model-bound on POST, and isn't initialized in the ctor → it'snullwhen the visitor invokes the getter →ArgumentNullException: Value cannot be null. (Parameter 'source')thrown before the controller action runs. Classic MVC5's validator never invoked this getter, so the bug was latent.Fix — make the display-only getter null-safe (sync + async DTOs):
Minimal by design: no ctor/mapping changes, no controller changes, purely guards the getter.
Scope note
This touches
ServiceLayer(2 files), which was migrated in a sibling subsession — but it's a genuine web-blocking runtime bug with no viable fix in the web project (the DTO is the validated model, and[ValidateNever]isn't available without pulling an ASP.NET Core MVC reference into the service layer). No DataLayer/BizLayer/Tests changes.Verification
dotnet build SampleWebApp/SampleWebApp.csprojsucceeds on net10.0. Re-testing Post create/edit end-to-end against SQL Server; results posted as a PR comment.Link to Devin session: https://app.devin.ai/sessions/395506e0330e4a789b2aec401bd66cf7
Devin Review