Skip to content

Conversation

tobias-wilfert
Copy link
Member

We would like to be able to send a custom attachment type, this makes it such that this is possible.

@tobias-wilfert tobias-wilfert self-assigned this Oct 7, 2025
Copy link

github-actions bot commented Oct 7, 2025

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

Generated by 🚫 dangerJS against 42033ae

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for custom attachment types by extending the AttachmentType enum to include arbitrary string values. This allows users to send attachments with custom type identifiers beyond the predefined Sentry attachment types.

  • Adds a Custom(String) variant to the AttachmentType enum
  • Updates the as_str method to work with borrowed values and handle custom types
  • Includes deserialization tests for the new custom attachment functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


/// The different types an attachment can have.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Deserialize)]
#[derive(Debug, Clone, Eq, PartialEq, Deserialize)]
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Removing Copy trait from the enum will impact performance for small operations. Consider keeping Copy and use Cow<'static, str> for the Custom variant to maintain zero-cost abstractions for predefined types while supporting custom strings.

Copilot uses AI. Check for mistakes.

filename = self.filename,
length = self.buffer.len(),
at = self.ty.unwrap_or_default().as_str(),
at = self.ty.clone().unwrap_or_default().as_str(),
Copy link

Copilot AI Oct 7, 2025

Choose a reason for hiding this comment

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

Unnecessary clone operation. Since as_str now takes &self, you can use self.ty.as_ref().unwrap_or(&AttachmentType::default()).as_str() to avoid cloning the attachment type.

Suggested change
at = self.ty.clone().unwrap_or_default().as_str(),
at = self.ty.as_ref().unwrap_or(&AttachmentType::default()).as_str(),

Copilot uses AI. Check for mistakes.

Copy link
Member

Choose a reason for hiding this comment

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

maybe a .as_ref().map(|a| a.as_str()).unwrap_or_default() would be even more concise (and avoid the clone).

Copy link
Member Author

Choose a reason for hiding this comment

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

This .as_ref().map(|a| a.as_str()).unwrap_or_default() will yield and empty str rather than event.attachment so not sure we want to change this (at least in this PR).

Copy link
Member Author

Choose a reason for hiding this comment

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

I can still do the explicit unwrap_or though that one should work.

Copy link

codecov bot commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 92.30769% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.79%. Comparing base (34b27b5) to head (42033ae).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #916      +/-   ##
==========================================
+ Coverage   73.76%   73.79%   +0.02%     
==========================================
  Files          64       64              
  Lines        7533     7544      +11     
==========================================
+ Hits         5557     5567      +10     
- Misses       1976     1977       +1     

cursor[bot]

This comment was marked as outdated.

@tobias-wilfert tobias-wilfert changed the title feat(types): Add custom attachment type feat(types): Add custom variant to AttachmentType Oct 8, 2025
filename = self.filename,
length = self.buffer.len(),
at = self.ty.unwrap_or_default().as_str(),
at = self.ty.clone().unwrap_or_default().as_str(),
Copy link
Member

Choose a reason for hiding this comment

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

maybe a .as_ref().map(|a| a.as_str()).unwrap_or_default() would be even more concise (and avoid the clone).

@tobias-wilfert tobias-wilfert merged commit b99eb46 into master Oct 8, 2025
19 checks passed
@tobias-wilfert tobias-wilfert deleted the tobias-wilfert/feat/add-custom-attachment-type branch October 8, 2025 09:00
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.

3 participants