From 85d16a4354cdcb5c27edba38401ae255029aa0d6 Mon Sep 17 00:00:00 2001 From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> Date: Tue, 14 Jan 2025 11:18:36 +0100 Subject: [PATCH] V13: Show validation error, when saving invalid media (#17961) * Don't save invalid media * Revert "Don't save invalid media" This reverts commit c4b6acf54282753476678a5027c371ac2d8a72b0. * Still allow save, but show validation error, not popup error * Add clarifying comment --- src/Umbraco.Web.BackOffice/Controllers/MediaController.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs index db47ba599f..abd1b2b787 100644 --- a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs +++ b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs @@ -471,7 +471,8 @@ public class MediaController : ContentControllerBase null); // media are all invariant // we will continue to save if model state is invalid, however we cannot save if critical data is missing. - // TODO: Allowing media to be saved when it is invalid is odd - media doesn't have a publish phase so suddenly invalid data is allowed to be 'live' + // this is a design decision, to continue to be able to save invalid content + // as you can do the same with documents. This will be removed in a future version. if (!ModelState.IsValid) { // check for critical data validation issues, we can't continue saving if this data is invalid @@ -495,10 +496,10 @@ public class MediaController : ContentControllerBase // return the updated model MediaItemDisplay? display = _umbracoMapper.Map(contentItem.PersistedContent); - // lastly, if it is not valid, add the model state to the outgoing object and throw a 403 + // lastly, if it is not valid, add the model state to the outgoing object. if (!ModelState.IsValid) { - return ValidationProblem(display, ModelState, StatusCodes.Status403Forbidden); + return ValidationProblem(display, ModelState); } // put the correct msgs in