Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
-->
- Adding a "web app" configuration profile (#11447)
- Add JitTrace Files for v4.1045
- Adding empty remote message check in the SystemLogger (#11473)
13 changes: 8 additions & 5 deletions src/WebJobs.Script.WebHost/Extensions/ExceptionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ public static (string InnerExceptionType, string InnerExceptionMessage, string D
var formattedDetails = exception.ToFormattedString();

if (exception is FunctionInvocationException && baseException is RpcException { RemoteMessage: var remoteMsg }
&& remoteMsg is not null)
&& !string.IsNullOrWhiteSpace(remoteMsg))
{
var redacted = GetRedactedExceptionMessage(remoteMsg);

var innerExceptionMessage = Sanitizer.Sanitize(
originalMessage.Replace(remoteMsg, redacted, StringComparison.Ordinal));
var innerExceptionMessage = string.IsNullOrWhiteSpace(originalMessage)
Comment thread
RohitRanjanMS marked this conversation as resolved.
? string.Empty
: Sanitizer.Sanitize(originalMessage.Replace(remoteMsg, redacted, StringComparison.Ordinal));
Comment thread
RohitRanjanMS marked this conversation as resolved.
Outdated

var detailsSanitized = Sanitizer.Sanitize(
formattedDetails.Replace(remoteMsg, redacted, StringComparison.Ordinal));

Comment thread
RohitRanjanMS marked this conversation as resolved.
var detailsSanitized = string.IsNullOrWhiteSpace(formattedDetails)
? string.Empty
: Sanitizer.Sanitize(formattedDetails.Replace(remoteMsg, redacted, StringComparison.Ordinal));
Comment thread
RohitRanjanMS marked this conversation as resolved.
Outdated

return (innerType, innerExceptionMessage, detailsSanitized, formattedMessage);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs.Script.Workers.Rpc;
using Xunit;

namespace Microsoft.Azure.WebJobs.Script.Tests.Extensions
Expand Down Expand Up @@ -33,5 +35,52 @@ public void GetExceptionDetails_ReturnsExpectedResult()
Assert.Contains("at Microsoft.Azure.WebJobs.Script.Tests.Extensions.ExceptionExtensionsTests.GetExceptionDetails_ReturnsExpectedResult()", exceptionDetails);
Assert.Contains("ExceptionExtensionsTests.cs : 20", exceptionDetails);
}

[Fact]
public void GetExceptionDetails_Rpc()
{
string rpcMessage = "rpcMessage";
Exception innerException = new RpcException("result", rpcMessage, "stack");
Exception outerException = new FunctionInvocationException("message", innerException);
Exception fullException;

try
{
throw outerException;
}
catch (Exception e)
{
fullException = e;
}
Comment thread
RohitRanjanMS marked this conversation as resolved.

(string exceptionType, string exceptionMessage, string exceptionDetails, string formattedText) = fullException.GetSanitizedExceptionDetails("safe text");
Comment thread
RohitRanjanMS marked this conversation as resolved.

Assert.Equal("Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException", exceptionType);
Assert.DoesNotContain(rpcMessage, exceptionMessage);
Assert.DoesNotContain(rpcMessage, exceptionDetails);
}

[Fact]
public void GetExceptionDetails_Rpc_Empty()
{
Exception innerException = new RpcException(string.Empty, string.Empty, string.Empty);
Exception outerException = new FunctionInvocationException(string.Empty, innerException);
Exception fullException;

try
{
throw outerException;
}
catch (Exception e)
{
fullException = e;
}
Comment thread
RohitRanjanMS marked this conversation as resolved.

(string exceptionType, string exceptionMessage, string exceptionDetails, string formattedText) = fullException.GetSanitizedExceptionDetails("safe text");
Comment thread
RohitRanjanMS marked this conversation as resolved.
Outdated

Assert.Equal("Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException", exceptionType);
Assert.Equal("Result: \nType: \nException: \nStack: ", exceptionMessage);
Assert.Contains("safe text", formattedText);
}
}
}
Loading