Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 1 addition & 3 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
<!-- Please add your release notes in the following format:
- My change description (#PR)
-->
-->
- Update Python Worker Version to [4.40.2](https://github.com/Azure/azure-functions-python-worker/releases/tag/4.40.2)
- Add JitTrace Files for v4.1044
- Adding empty remote message check in the SystemLogger (#11473)
2 changes: 1 addition & 1 deletion src/Directory.Version.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>4.1044.300</VersionPrefix>
<VersionPrefix>4.1044.350</VersionPrefix>
<UpdateBuildNumber>true</UpdateBuildNumber>
</PropertyGroup>
</Project>
12 changes: 7 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,17 @@ 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)
? string.Empty
: Sanitizer.Sanitize(originalMessage.Replace(remoteMsg, redacted, StringComparison.Ordinal));

var detailsSanitized = Sanitizer.Sanitize(
formattedDetails.Replace(remoteMsg, redacted, StringComparison.Ordinal));
var detailsSanitized = string.IsNullOrWhiteSpace(formattedDetails)
? string.Empty
: Sanitizer.Sanitize(formattedDetails.Replace(remoteMsg, redacted, StringComparison.Ordinal));

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 @@ -31,7 +33,55 @@ public void GetExceptionDetails_ReturnsExpectedResult()
Assert.Contains("System.Exception : some outer exception ---> System.InvalidOperationException : Some inner exception", exceptionDetails);
Assert.Contains("End of inner exception", exceptionDetails);
Assert.Contains("at Microsoft.Azure.WebJobs.Script.Tests.Extensions.ExceptionExtensionsTests.GetExceptionDetails_ReturnsExpectedResult()", exceptionDetails);
Assert.Contains("ExceptionExtensionsTests.cs : 20", exceptionDetails);
Assert.Contains("ExceptionExtensionsTests.cs", 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;
}

(string exceptionType, string exceptionMessage, string exceptionDetails, string formattedText) = fullException.GetSanitizedExceptionDetails("safe text");

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

[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;
}

(string exceptionType, string exceptionMessage, _, string formattedText) = fullException.GetSanitizedExceptionDetails("safe text");

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