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

fix(server): Assign a default name for unnamed attachments #769

Merged
merged 2 commits into from
Sep 11, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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