-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix context object with circular reference prevents event from being sent #2210
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mattjohnsonpint
commented
Mar 4, 2023
mattjohnsonpint
commented
Mar 4, 2023
@@ -448,10 +529,19 @@ public static void Deconstruct(this JsonProperty jsonProperty, out string name, | |||
// Render an empty JSON object instead of null. This allows a round trip where this property name is the | |||
// key to a map which would otherwise not be set and result in a different object. | |||
// This affects envelope size which isn't recomputed after a roundtrip. | |||
if (originalPropertyDepth == writer.CurrentDepth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the actual cause of the original bug. The assumption that the depth won't have changed is true when a property being serialized throws an exception on its own, but is false when an exception occurs for reaching max depth.
bruno-garcia
reviewed
Mar 4, 2023
SeanFeldman
reviewed
Mar 6, 2023
bruno-garcia
approved these changes
Mar 6, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a circular reference exists in an object being added to an event as contexts or extras, the SDK will now do the following:
System.Text.Json
(depth = 64), then it will be serialized normally. This is covers the majority of cases.ReferenceHandler.Preserve
option provided bySystem.Text.Json
. This results in a much smaller object graph, but one that has been tagged with$id
and$ref
metadata instead of materializing the references.To opt out of this behavior, set
SentryOptions.JsonPreserveReferences = false
. If serialization were to fail due to exceeding the max depth, then the object graph will be truncated at that depth. This was the intended behavior of the previous implementation, though it had a bug which has now been fixed as well.In any case, the net result is that such an object no longer prevents the event from being sent to Sentry.
Fixes #2209
Also:
TimeSpan
,DateOnly
, andTimeOnly
to the list of directly-serializable types, since they were in the same code path.ReferenceHandler.Preserve
requires a minimum dependency on STJ 5. We already had5.0.2
as the min dependency on .NET Framework and .NET Standard, but we are still building for .NET Core 3.0 so we need to bump the STJ dependency there as well. This only affects thenetcoreapp3.0
target. .NET 5+ will continue to use the STJ provided with the .NET SDK. (We'll drop these old targets in the next major.)