Commit 6cb5d7db authored by LeoniePhiline's avatar LeoniePhiline Committed by Vitali Tatarintev

fix(error-tracking): Accept empty transaction string in sentry payload

Fixes #353153
parent e6b5fc5d
......@@ -60,7 +60,7 @@ module ErrorTracking
end
def actor
return event['transaction'] if event['transaction']
return event['transaction'] if event['transaction'].present?
# Some SDKs do not have a transaction attribute.
# So we build it by combining function name and module name from
......
{
"event_id": "dquJXuPF9sP1fMy5RpKo979xUALjNDQB",
"timestamp": 1645191605.123456,
"platform": "php",
"sdk": {
"name": "sentry.php",
"version": "3.3.7"
},
"logger": "php",
"transaction": "",
"server_name": "oAjA5zTgIjqP",
"release": "C0FFEE",
"environment": "Development/Berlin",
"exception": {
"values": [
{
"type": "TestException",
"value": "Sentry test exception",
"stacktrace": {
"frames": [
{
"filename": "/src/Path/To/Class.php",
"lineno": 3,
"in_app": true,
"abs_path": "/var/www/html/src/Path/To/Class.php",
"function": "Path\\To\\Class::method",
"raw_function": "Path\\To\\Class::method",
"pre_context": [
"// Pre-context"
],
"context_line": "throw new TestException('Sentry test exception');",
"post_context": [
"// Post-context"
]
}
]
},
"mechanism": {
"type": "generic",
"handled": true
}
}
]
}
}
......@@ -171,6 +171,12 @@ RSpec.describe API::ErrorTracking::Collector do
it_behaves_like 'successful request'
end
context 'when JSON key transaction is empty string' do
let_it_be(:raw_event) { fixture_file('error_tracking/php_empty_transaction.json') }
it_behaves_like 'successful request'
end
context 'sentry_key as param and empty headers' do
let(:url) { "/error_tracking/collector/api/#{project.id}/store?sentry_key=#{sentry_key}" }
let(:headers) { {} }
......
......@@ -51,25 +51,30 @@ RSpec.describe ErrorTracking::CollectErrorService do
end
end
context 'unusual payload' do
context 'with unusual payload' do
let(:modified_event) { parsed_event }
let(:event) { described_class.new(project, nil, event: modified_event).execute }
context 'missing transaction' do
context 'when transaction is missing' do
it 'builds actor from stacktrace' do
modified_event.delete('transaction')
event = described_class.new(project, nil, event: modified_event).execute
expect(event.error.actor).to eq 'find()'
end
end
context 'when transaction is an empty string' do \
it 'builds actor from stacktrace' do
modified_event['transaction'] = ''
expect(event.error.actor).to eq 'find()'
end
end
context 'timestamp is numeric' do
context 'when timestamp is numeric' do
it 'parses timestamp' do
modified_event['timestamp'] = '1631015580.50'
event = described_class.new(project, nil, event: modified_event).execute
expect(event.occurred_at).to eq '2021-09-07T11:53:00.5'
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment