From f97671d40e43918631b75c73b043cf0c22d961e7 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Mon, 7 Apr 2025 11:43:02 -0700 Subject: [PATCH 1/2] handle the RegexMatchTimeoutException --- ...ptionTypeAndStackTraceFailureClassifier.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs b/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs index 3dac69d617..cc9e5b89f7 100644 --- a/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs +++ b/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs @@ -1,6 +1,7 @@ namespace ServiceControl.Recoverability { using System.Linq; + using System.Text.RegularExpressions; public class ExceptionTypeAndStackTraceFailureClassifier : IFailureClassifier { @@ -28,21 +29,28 @@ public string ClassifyFailure(ClassifiableMessageDetails failure) // We need to remove the message in order to make sure the stack trace parser does not get into catastrophic backtracking mode. exceptionStackTrace = exceptionStackTrace.Replace(exception.Message, string.Empty); } - - var firstStackTraceFrame = StackTraceParser.Parse(exceptionStackTrace, (frame, type, method, parameterList, parameters, file, line) => new StackFrame + try { - Type = type, - Method = method, - Params = parameterList, - File = file, - Line = line - }).FirstOrDefault(); + var firstStackTraceFrame = StackTraceParser.Parse(exceptionStackTrace, (frame, type, method, parameterList, parameters, file, line) => new StackFrame + { + Type = type, + Method = method, + Params = parameterList, + File = file, + Line = line + }).FirstOrDefault(); - if (firstStackTraceFrame != null) + if (firstStackTraceFrame != null) + { + return exception.ExceptionType + ": " + firstStackTraceFrame.ToMethodIdentifier(); + } + } + catch (RegexMatchTimeoutException) { - return exception.ExceptionType + ": " + firstStackTraceFrame.ToMethodIdentifier(); + return GetNonStandardClassification(exception.ExceptionType); } + return GetNonStandardClassification(exception.ExceptionType); } From 099d98ad0da489c1729480ca9227cfc759201f28 Mon Sep 17 00:00:00 2001 From: Jayanthi Date: Mon, 7 Apr 2025 14:17:40 -0700 Subject: [PATCH 2/2] Update src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs Co-authored-by: Nick Gallegos --- .../Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs b/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs index cc9e5b89f7..bdb5584c84 100644 --- a/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs +++ b/src/ServiceControl/Recoverability/Grouping/Groupers/ExceptionTypeAndStackTraceFailureClassifier.cs @@ -47,7 +47,7 @@ public string ClassifyFailure(ClassifiableMessageDetails failure) } catch (RegexMatchTimeoutException) { - return GetNonStandardClassification(exception.ExceptionType); + // Intentionally empty - if the parsing fails, treat it as if exception.Message is null or empty, not throw an exception }