diff --git a/extensions/Worker.Extensions.Http.AspNetCore/release_notes.md b/extensions/Worker.Extensions.Http.AspNetCore/release_notes.md index 7b0801352..7b79522ed 100644 --- a/extensions/Worker.Extensions.Http.AspNetCore/release_notes.md +++ b/extensions/Worker.Extensions.Http.AspNetCore/release_notes.md @@ -6,4 +6,4 @@ ### Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore <version> -- <entry> +- Fixed a bug that would lead to an empty exception message in some model binding failures. diff --git a/extensions/Worker.Extensions.Http.AspNetCore/src/FromBodyConversionFeature.cs b/extensions/Worker.Extensions.Http.AspNetCore/src/FromBodyConversionFeature.cs index 95743e32e..c2d50b0b9 100644 --- a/extensions/Worker.Extensions.Http.AspNetCore/src/FromBodyConversionFeature.cs +++ b/extensions/Worker.Extensions.Http.AspNetCore/src/FromBodyConversionFeature.cs @@ -84,7 +84,16 @@ internal sealed class FromBodyConversionFeature : IFromBodyConversionFeature foreach (var error in dictionary.Errors) { - messageBuilder.AppendLine(error.ErrorMessage); + if (error is null) + { + continue; + } + + var message = string.IsNullOrEmpty(error.ErrorMessage) + ? error.Exception?.Message + : error.ErrorMessage; + + messageBuilder.AppendLine(message); } }