Skip to content

feat: Add max_attachment_size to SentryOptions #219

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

Closed
wants to merge 3 commits into from

Conversation

limbonaut
Copy link
Collaborator

@limbonaut limbonaut commented Jul 1, 2025

Copy link
Contributor

github-actions bot commented Jul 1, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 211e320


## Fixes
### Fixes
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Quick fix for changelog blunder

@limbonaut limbonaut marked this pull request as ready for review July 1, 2025 13:10
@@ -65,6 +65,7 @@ class SentryOptions : public RefCounted {
bool attach_screenshot = false;
sentry::Level screenshot_level = sentry::LEVEL_FATAL;
bool attach_scene_tree = false;
int64_t max_attachment_size = 20 * 1024 * 1024; // 20 MiB
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to hard code a value here? Is this compressed or decompressed?

max size is 20MB compressed (100MB uncompressed) for the whole request. So if we're doing 1 request only with attachment that is it can be a lot bigger than 20MB before we compress the file (assuming something that compresses OK).

Sentry is working on allowing much larger (probably Gigabyte+ in size) attachments. We'd need to come back and change all SDKs hard coding this size. See:

Is also an issue that we only apply this to Android but not sentry-native. (Does it exist on Cocoa)? (cc @romtsn @philipphofmann )

I think best approach for now is to print to console if larger than X (20MB perhaps), that the limit is documented here: https://docs.sentry.io/concepts/data-management/size-limits/ and that because the attached file is larger than that, it's likely going to be dropped. We could hard code a value to drop if larger then 100MB decompressed, because that will be dropped for now, for sure, for now. Also debug log and print to console. I think this behavior should be aligned across SDKs though too, so we should add this to sentry-native then.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bruno-garcia I believe this option is meant to set a limit on the mobile SDKs that can cache these attachments on the drive and control space usage this way. I copied the default value from the Android SDK, but we could remove the default, set it to 0, and when it’s 0, the limit won’t apply. I’m adding it based on the documentation:

Screenshot 2025-07-01 at 17 21 10

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we have the max attachment size on Cocoa: https://github.com/getsentry/sentry-cocoa/blob/bce9765eba9af4af7ad81ff7feb3684aed3ed684/Sources/Sentry/Public/SentryOptions.h#L248-L255

Yes, we should align this behaviour across the SDKs once we can upload larger attachments. On Cocoa, large attachements wouldn't work currently because we load the entire attachment into memory before sending it. We would need add streaming large files directly via the HTTP request instead of completely loading it into memory. We'll fix this once we get there.

@limbonaut
Copy link
Collaborator Author

limbonaut commented Jul 2, 2025

During the last sync, we decided against introducing this option, so I'm closing this.

@limbonaut limbonaut closed this Jul 2, 2025
@limbonaut limbonaut deleted the feat/max-attachment-size branch July 2, 2025 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants