Skip to content

Commit bd8354e

Browse files
committed
ref(attachments): Remove duplicated meta handling
1 parent b35e66d commit bd8354e

2 files changed

Lines changed: 58 additions & 7 deletions

File tree

relay-server/src/processing/trace_attachments/store.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,6 @@ fn convert_attributes(
134134
result.reserve(attributes.0.len() + 5);
135135

136136
for (name, attribute) in attributes {
137-
let meta = AttributeMeta {
138-
meta: IntoValue::extract_meta_tree(&attribute),
139-
};
140-
if let Some(meta) = meta.to_any_value() {
141-
result.insert(format!("sentry._meta.fields.attributes.{name}"), meta);
142-
}
143-
144137
let value = attribute
145138
.into_value()
146139
.and_then(|v| v.value.value.into_value());

tests/integration/test_attachmentsv2.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,64 @@ def test_standalone_attachment_store(
178178
assert stored.metadata.content_type == "text/plain"
179179

180180

181+
def test_standalone_attachment_attribute_meta_store(
182+
mini_sentry,
183+
relay,
184+
relay_with_processing,
185+
items_consumer,
186+
objectstore,
187+
):
188+
items_consumer = items_consumer()
189+
190+
project_id = 42
191+
project_config = mini_sentry.add_full_project_config(project_id)
192+
project_config["config"]["features"] = [
193+
"projects:span-v2-attachment-processing",
194+
"projects:trace-attachment-processing",
195+
]
196+
project_config["config"]["piiConfig"] = {
197+
"rules": {"strip_ips": {"type": "ip", "redaction": {"method": "remove"}}},
198+
"applications": {"**": ["strip_ips"]},
199+
}
200+
201+
objectstore = objectstore(usecase="trace_attachments", project_id=project_id)
202+
relay = relay(relay_with_processing(options=TEST_CONFIG), options=TEST_CONFIG)
203+
204+
attachment_metadata = create_attachment_metadata()
205+
attachment_metadata["attributes"] = {
206+
"user.ip": {"type": "string", "value": "192.168.1.1"},
207+
"safe.attribute": {"type": "string", "value": "keep this"},
208+
}
209+
attachment_body = b"This is some mock attachment content"
210+
metadata_bytes = json.dumps(attachment_metadata, separators=(",", ":")).encode(
211+
"utf-8"
212+
)
213+
combined_payload = metadata_bytes + attachment_body
214+
215+
envelope = create_attachment_envelope(project_config)
216+
envelope.add_item(
217+
Item(
218+
payload=PayloadRef(bytes=combined_payload),
219+
headers={
220+
"content_type": "application/vnd.sentry.trace-attachment",
221+
"meta_length": len(metadata_bytes),
222+
"length": len(combined_payload),
223+
"type": "attachment",
224+
},
225+
)
226+
)
227+
relay.send_envelope(project_id, envelope)
228+
229+
attributes = items_consumer.get_item()["attributes"]
230+
assert attributes["safe.attribute"] == {"stringValue": "keep this"}
231+
assert attributes["user.ip"] == {"stringValue": ""}
232+
assert attributes["sentry._meta.fields.attributes.user.ip"] == {
233+
"stringValue": '{"meta":{"value":{"":{"rem":[["strip_ips","x",0,0]],"len":11}}}}'
234+
}
235+
stored = objectstore.get(attachment_metadata["attachment_id"])
236+
assert stored.payload.read() == attachment_body
237+
238+
181239
@pytest.mark.parametrize(
182240
"invalid_headers,quantity,reason",
183241
[

0 commit comments

Comments
 (0)