feat: Sync attachments on Android, Windows, and Linux#2609
feat: Sync attachments on Android, Windows, and Linux#2609bitsandfoxes merged 5 commits intomainfrom
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧Deps
Other
Other
🤖 This preview updates automatically when you update the PR. |
|
| [DllImport(SentryLib)] | ||
| internal static extern IntPtr sentry_attach_file(string path); | ||
|
|
||
| [DllImport(SentryLib)] | ||
| internal static extern IntPtr sentry_attach_bytes(byte[] buf, UIntPtr buf_len, string filename); | ||
|
|
||
| [DllImport(SentryLib)] | ||
| internal static extern void sentry_clear_attachments(); |
There was a problem hiding this comment.
Bug: The contentType for attachments is silently discarded in the native implementation for Windows/Linux, as the P/Invoke calls sentry_attach_file and sentry_attach_bytes do not pass this parameter.
Severity: MEDIUM
Suggested Fix
Investigate if the underlying sentry-native C API supports setting the content type. If it does, update the P/Invoke signatures and the NativeScopeObserver.cs implementation to pass the contentType to the native layer. If not, add logging to warn the user that contentType is being ignored on native platforms.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/Sentry.Unity.Native/CFunctions.cs#L168-L175
Potential issue: The abstract `AddAttachment` method and its implementations in
`ScopeObserver` correctly handle a `contentType` parameter. However, the native
implementation for Windows/Linux in `NativeScopeObserver.cs` calls P/Invoke functions
(`sentry_attach_file` and `sentry_attach_bytes`) that do not accept a `contentType`.
This causes the content type information to be silently lost for attachments on these
platforms, creating an inconsistency with the Android implementation which correctly
preserves it. This degrades functionality by stripping metadata from native attachments.
Did we get this right? 👍 / 👎 to inform future reviews.
Builds on:
With this,
fileandbyteattachments get synced to the native layer on Android, Windows, and Linux and will be available on events originating from these layers.