Skip to content

Commit ec79b5f

Browse files
authored
fix(attachments): Add +json to placeholder content-type (#5752)
1 parent ee32116 commit ec79b5f

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

relay-server/src/envelope/content_type.rs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub enum ContentType {
3535
TraceMetricContainer,
3636
/// `application/vnd.sentry.trace-attachment`
3737
TraceAttachment,
38-
/// `application/vnd.sentry.attachment-ref`
38+
/// `application/vnd.sentry.attachment-ref+json`
3939
AttachmentRef,
4040
/// All integration content types.
4141
Integration(Integration),
@@ -58,7 +58,7 @@ impl ContentType {
5858
Self::SpanV2Container => "application/vnd.sentry.items.span.v2+json",
5959
Self::TraceMetricContainer => "application/vnd.sentry.items.trace-metric+json",
6060
Self::TraceAttachment => "application/vnd.sentry.trace-attachment",
61-
Self::AttachmentRef => "application/vnd.sentry.attachment-ref",
61+
Self::AttachmentRef => "application/vnd.sentry.attachment-ref+json",
6262
Self::Integration(integration) => integration.as_content_type(),
6363
}
6464
}
@@ -104,7 +104,9 @@ impl ContentType {
104104
|| ct.eq_ignore_ascii_case("application/vnd.sentry.attachment.v2")
105105
{
106106
Some(Self::TraceAttachment)
107-
} else if ct.eq_ignore_ascii_case(Self::AttachmentRef.as_str()) {
107+
} else if ct.eq_ignore_ascii_case(Self::AttachmentRef.as_str())
108+
|| ct.eq_ignore_ascii_case("application/vnd.sentry.attachment-ref")
109+
{
108110
Some(Self::AttachmentRef)
109111
} else {
110112
Integration::from_content_type(ct).map(Self::Integration)
@@ -186,3 +188,20 @@ impl serde::Serialize for ContentType {
186188
}
187189

188190
relay_common::impl_str_de!(ContentType, "a content type string");
191+
192+
#[cfg(test)]
193+
mod tests {
194+
use super::*;
195+
196+
#[test]
197+
fn attachment_ref_roundtrip() {
198+
let canonical_name = "application/vnd.sentry.attachment-ref+json";
199+
let ct = ContentType::from_str(canonical_name).unwrap();
200+
assert_eq!(ct, ContentType::AttachmentRef);
201+
assert_eq!(canonical_name, ct.as_str());
202+
203+
let legacy_alias = "application/vnd.sentry.attachment-ref";
204+
let ct = ContentType::from_str(legacy_alias).unwrap();
205+
assert_eq!(ct, ContentType::AttachmentRef);
206+
}
207+
}

tests/integration/test_attachment_ref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def make_envelope(event_id):
1313
payload=PayloadRef(bytes=b""),
1414
headers={
1515
"type": "attachment",
16-
"content_type": "application/vnd.sentry.attachment-ref",
16+
"content_type": "application/vnd.sentry.attachment-ref+json",
1717
"attachment_length": 1,
1818
},
1919
)

0 commit comments

Comments
 (0)