mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
@@ -418,6 +418,59 @@ class IngestViewTestCase(TransactionTestCase):
|
||||
|
||||
self.assertEqual('SIGABRT: Fatal Error: SIGABRT', Event.objects.get().title())
|
||||
|
||||
def test_envelope_endpoint_unsupported_type(self):
|
||||
# dirty copy/paste from the integration test, let's start with "something", we can always clean it later.
|
||||
project = Project.objects.create(name="test")
|
||||
|
||||
sentry_auth_header = get_header_value(f"http://{ project.sentry_key }@hostisignored/{ project.id }")
|
||||
|
||||
for i, include_event_id in enumerate([True, False]):
|
||||
data = {}
|
||||
event_id = uuid.uuid4().hex
|
||||
|
||||
data_bytes = json.dumps(data).encode("utf-8")
|
||||
data_bytes = (
|
||||
b'{"event_id": "%s"}\n{"type": "unsupported_type"}\n' % event_id.encode("utf-8") + data_bytes)
|
||||
|
||||
response = self.client.post(
|
||||
f"/api/{ project.id }/envelope/",
|
||||
content_type="application/json",
|
||||
headers={
|
||||
"X-Sentry-Auth": sentry_auth_header,
|
||||
},
|
||||
data=data_bytes,
|
||||
)
|
||||
self.assertEqual(
|
||||
200, response.status_code, response.content if response.status_code != 302 else response.url)
|
||||
|
||||
self.assertEqual(0, Event.objects.count())
|
||||
|
||||
def test_envelope_endpoint_unsupported_type_without_event_id(self):
|
||||
# dirty copy/paste from the integration test, let's start with "something", we can always clean it later.
|
||||
project = Project.objects.create(name="test")
|
||||
|
||||
sentry_auth_header = get_header_value(f"http://{ project.sentry_key }@hostisignored/{ project.id }")
|
||||
|
||||
for i, include_event_id in enumerate([True, False]):
|
||||
data = {}
|
||||
|
||||
data_bytes = json.dumps(data).encode("utf-8")
|
||||
data_bytes = (
|
||||
b'{}\n{"type": "unsupported_type"}\n' + data_bytes)
|
||||
|
||||
response = self.client.post(
|
||||
f"/api/{ project.id }/envelope/",
|
||||
content_type="application/json",
|
||||
headers={
|
||||
"X-Sentry-Auth": sentry_auth_header,
|
||||
},
|
||||
data=data_bytes,
|
||||
)
|
||||
self.assertEqual(
|
||||
200, response.status_code, response.content if response.status_code != 302 else response.url)
|
||||
|
||||
self.assertEqual(0, Event.objects.count())
|
||||
|
||||
@tag("samples")
|
||||
def test_envelope_endpoint_reused_ids_different_exceptions(self):
|
||||
# dirty copy/paste from test_envelope_endpoint,
|
||||
|
||||
@@ -716,6 +716,10 @@ class IngestEnvelopeAPIView(BaseIngestAPIView):
|
||||
event_count = len(items_by_type.get("event", []))
|
||||
minidump_count = len(items_by_type.get("attachment", []))
|
||||
|
||||
if event_count + minidump_count == 0:
|
||||
logger.info("no event or minidump found in envelope, ignoring this envelope.")
|
||||
return HttpResponse()
|
||||
|
||||
if event_count > 1 or minidump_count > 1:
|
||||
# TODO: we do 2 passes (one for storing, one for calling the right task), and we check certain conditions
|
||||
# only on the second pass; this means that we may not clean up after ourselves yet.
|
||||
|
||||
Reference in New Issue
Block a user