Skip to content

Commit

Permalink
fix(server): Assign a default name for unnamed attachments (#769)
Browse files Browse the repository at this point in the history
Assigns a fallback name of "Unnamed Attachment" if an attachment envelope item
is ingested without a `filename` header. This can be considered a non-fatal
implementation error in SDKs.
  • Loading branch information
jan-auer authored Sep 11, 2020
1 parent ef78ae1 commit 77d2f90
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Add a standalone tool to document metrics in JSON or YAML. ([#752](https://github.com/getsentry/relay/pull/752))
- Emit `processing.event.produced` for user report and session Kafka messages. ([#757](https://github.com/getsentry/relay/pull/757))
- Improve performance of event processing by avoiding regex clone. ([#767](https://github.com/getsentry/relay/pull/767))
- Assign a default name for unnamed attachments, which prevented attachments from being stored in Sentry. ([#769](https://github.com/getsentry/relay/pull/769))

## 20.8.0

Expand Down
12 changes: 9 additions & 3 deletions relay-server/src/actors/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ lazy_static::lazy_static! {
Uuid::new_v5(&Uuid::NAMESPACE_URL, b"https://sentry.io/#did");
}

/// Fallback name used for attachment items without a `filename` header.
const UNNAMED_ATTACHMENT: &str = "Unnamed Attachment";

#[derive(Fail, Debug)]
pub enum StoreError {
#[fail(display = "failed to send kafka message")]
Expand Down Expand Up @@ -117,7 +120,10 @@ impl StoreForwarder {

Ok(ChunkedAttachment {
id,
name: item.filename().map(str::to_owned),
name: match item.filename() {
Some(name) => name.to_owned(),
None => UNNAMED_ATTACHMENT.to_owned(),
},
content_type: item
.content_type()
.map(|content_type| content_type.as_str().to_owned()),
Expand Down Expand Up @@ -214,8 +220,8 @@ struct ChunkedAttachment {
/// The triple `(project_id, event_id, id)` identifies an attachment uniquely.
id: String,

/// File name of the attachment file. Should not be `None`.
name: Option<String>,
/// File name of the attachment file.
name: String,

/// Content type of the attachment payload.
content_type: Option<String>,
Expand Down

0 comments on commit 77d2f90

Please # to comment.