FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

ReplaceRenderer may throw NullReferenceException

Open pbolduc opened this issue 4 years ago • 0 comments

We were testing some template rendering and were getting a NullReferenceException when this code is executing. I believe one of the model properties is null. I would think ReplaceRenderer should ether skip null properties or throw a custom exception representing this error.

https://github.com/lukencode/FluentEmail/blob/a94b1f3d084476dfeaeedd1845cdecd2b6718dbc/src/FluentEmail.Core/Defaults/ReplaceRenderer.cs#L13

The problem is this part pi.GetValue(model, null).ToString() when the property is null. The ToString() function call causes the exception.

pbolduc avatar Sep 23 '21 19:09 pbolduc