Skip to content
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

Fixed envelopes with large attachments persist on disk #3328

Merged
merged 4 commits into from
Apr 29, 2024

Conversation

jamescrosswell
Copy link
Collaborator

@jamescrosswell jamescrosswell commented Apr 25, 2024

Resolves #3209

Problem summary

This is only a problem when using the CachingTransport. The issue is in two parts. Firstly here:

if (string.Equals(item.TryGetType(), "attachment", StringComparison.OrdinalIgnoreCase) &&
item.TryGetLength() > _options.MaxAttachmentSize)

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:

@jamescrosswell jamescrosswell changed the title Fixed Envelopes with large attachments persist on disk Fixed envelopes with large attachments persist on disk Apr 25, 2024
@@ -76,6 +76,21 @@ public EnvelopeItem(IReadOnlyDictionary<string, object?> header, ISerializable p
var value => Convert.ToInt64(value) // can be int, long, or another numeric type
};

internal long? TryGetOrRecalculateLength()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand how we get here or how that fixes the issue - even if it does (which I believe).
The attachment size did not get read correctly from the header? How/why not? Should it have been set in the first place? And if we're recalculating it here, should it not end up being set now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put all of that in the details for the issue itself... but I just moved it into the details of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the length ends up in the header during serialization and gets removed during deserialization because of trust-issues. Fair enough.
But is this not a bug in the caching transport then? Should the length not be set back on the header during serialization?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not trying to bikeshed here, I genuinely don't get how it works.

Copy link
Collaborator Author

@jamescrosswell jamescrosswell Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you have to read Matt's PR in order to understand where the length is being calcluated now.

@jamescrosswell jamescrosswell merged commit 0a8a92a into main Apr 29, 2024
20 checks passed
@jamescrosswell jamescrosswell deleted the big-attachments-persist branch April 29, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to send envelopes persist on disk
2 participants