getsentry / sentry-dotnet

Sentry SDK for .NET
https://docs.sentry.io/platforms/dotnet
MIT License
566 stars 203 forks source link

Fixed envelopes with large attachments persist on disk #3328

Closed jamescrosswell closed 2 weeks ago

jamescrosswell commented 2 weeks ago

Resolves https://github.com/getsentry/sentry-dotnet/issues/3209

Problem summary

This is only a problem when using the CachingTransport. The issue is in two parts. Firstly here: https://github.com/getsentry/sentry-dotnet/blob/59f31642c10f8c8159d8294e0a48536b14ad4cd0/src/Sentry/Http/HttpTransportBase.cs#L129-L130

If the length header has not been set then the envelope item is not correctly identified as being too big... the result is that we only get an exception when we try to send the attachment in the envelope to Sentry.

The second factor contributing to the issue is that when deserializing an envelope from the cache, this header gets removed: https://github.com/getsentry/sentry-dotnet/blob/59f31642c10f8c8159d8294e0a48536b14ad4cd0/src/Sentry/Protocol/Envelopes/EnvelopeItem.cs#L446