question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception serializing envelope with `WriteDynamicValue`

See original GitHub issue

No repro yet:

Exception:
System.InvalidOperationException: Method may only be called on a Type for which Type.IsGenericParameter is true.
   at System.RuntimeType.get_DeclaringMethod()
   at System.Text.Json.JsonPropertyInfo`1.GetMemberAndWriteJson(Object obj, WriteStack& state, Utf8JsonWriter writer)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1.OnTryWrite(Utf8JsonWriter writer, T value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.Serialization.JsonConverter`1.WriteCore(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.Serialization.JsonConverter`1.WriteCoreAsObject(Utf8JsonWriter writer, Object value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.JsonSerializer.WriteCore[TValue](JsonConverter jsonConverter, Utf8JsonWriter writer, TValue& value, JsonSerializerOptions options, WriteStack& state)
   at System.Text.Json.JsonSerializer.WriteCore[TValue](Utf8JsonWriter writer, TValue& value, Type inputType, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Serialize[TValue](Utf8JsonWriter writer, TValue& value, Type type, JsonSerializerOptions options)
   at System.Text.Json.JsonSerializer.Serialize[TValue](Utf8JsonWriter writer, TValue value, JsonSerializerOptions options)
   at Sentry.JsonSerializableExtensions.WriteDynamicValue(Utf8JsonWriter writer, Object value) in /_/src/Sentry/IJsonSerializable.cs:line 106
   at Sentry.SentryEvent.WriteTo(Utf8JsonWriter writer) in /_/src/Sentry/SentryEvent.cs:line 344
   at Sentry.Protocol.Envelopes.JsonSerializable.SerializeAsync(Stream stream, CancellationToken cancellationToken) in /_/src/Sentry/Envelopes/JsonSerializable.cs:line 27
   at Sentry.Protocol.Envelopes.JsonSerializable.SerializeAsync(Stream stream, CancellationToken cancellationToken) in /_/src/Sentry/Envelopes/JsonSerializable.cs:line 28
   at Sentry.Protocol.Envelopes.EnvelopeItem.BufferPayloadAsync(CancellationToken cancellationToken) in /_/src/Sentry/Envelopes/EnvelopeItem.cs:line 64
   at Sentry.Protocol.Envelopes.EnvelopeItem.SerializeAsync(Stream stream, CancellationToken cancellationToken) in /_/src/Sentry/Envelopes/EnvelopeItem.cs:line 101
   at Sentry.Protocol.Envelopes.Envelope.SerializeAsync(Stream stream, CancellationToken cancellationToken) in /_/src/Sentry/Envelopes/Envelope.cs:line 66
   at Sentry.Internal.Http.EnvelopeHttpContent.SerializeToStreamAsync(Stream stream, TransportContext context) in /_/src/Sentry/Internal/Http/EnvelopeHttpContent.cs:line 16
   at System.Net.Http.HttpContent.<CopyToAsync>g__WaitAsync|56_0(ValueTask copyTask)
   at Sentry.Internal.Http.GzipBufferedRequestBodyHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /_/src/Sentry/Internal/Http/GzipBufferedRequestBodyHandler.cs:line 58
   at Sentry.Internal.Http.RetryAfterHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) in /_/src/Sentry/Internal/Http/RetryAfterHandler.cs:line 64
   at System.Net.Http.HttpClient.SendAsyncCore(HttpRequestMessage request, HttpCompletionOption completionOption, Boolean async, Boolean emitTelemetryStartStop, CancellationToken cancellationToken)
   at Sentry.Internal.Http.HttpTransport.SendEnvelopeAsync(Envelope envelope, CancellationToken cancellationToken) in /_/src/Sentry/Internal/Http/HttpTransport.cs:line 113
   at Sentry.Internal.BackgroundWorker.WorkerAsync() in /_/src/Sentry/Internal/BackgroundWorker.cs:line 134

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bruno-garciacommented, May 10, 2021

I think we need to ignore this error. Log out with the diag logger and carry on. We only use this on Extra and Contexts and it’s better to lose that than the event.

0reactions
bruno-garciacommented, Nov 8, 2021

There was an attempt to pull the serialization logic out of the models, so we could pass a logger instance to it, and handle this: https://github.com/getsentry/sentry-dotnet/pull/965/

Read more comments on GitHub >

github_iconTop Results From Across the Web

XmlSerializer throws exception when serializing ...
I'm trying to use the System.Xml.Serialization.XmlSerializer to serialize a dynamically loaded (and compiled class). If I build the class in ...
Read more >
Problem with MassTransit deserialization · Issue #1191
SerializationException : An exception occurred while deserializing the message envelope ---> System.ArgumentNullException: Value cannot be ...
Read more >
Envelopes | Sentry Developer Documentation
This section defines the Envelope data format and serialization. For details on data integrity and a list of valid Item types refer to...
Read more >
Creating and Modifying Dynamic Entities | Using JSON
Any ObjectScript expression that evaluates to a value rather than an object reference can be serialized to a JSON literal string.
Read more >
Quick Reference for Dynamic Entity Methods | Using JSON
This section provides an overview and references for each of the available dynamic entity methods. Dynamic entities are instances of %Library.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found