Skip to content

Commit cb1caca

Browse files
niemyjskiCopilot
andcommitted
fix(aspnetcore): guard DiagnosticListener reflection from TargetInvocationException
Wrap GetPropertyValue in try-catch to prevent PropertyInfo.GetValue from throwing through OnNext, which violates the IObserver<T> contract and could cause DiagnosticListener to permanently unsubscribe the observer, silently breaking all exception reporting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b8b9084 commit cb1caca

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/Platforms/Exceptionless.AspNetCore/ExceptionlessDiagnosticListener.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,13 @@ private static object GetPropertyValue(object payload, string propertyName) {
7070
if (payload is null)
7171
return null;
7272

73-
return payload.GetType()
74-
.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.IgnoreCase)?
75-
.GetValue(payload);
73+
try {
74+
return payload.GetType()
75+
.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.IgnoreCase)?
76+
.GetValue(payload);
77+
} catch {
78+
return null;
79+
}
7680
}
7781
}
7882
}

0 commit comments

Comments
 (0)