Commit 22056975 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch '119205-500-when-error-stack-trace-is-empty' into 'master'

Resolve "500 when error stack trace is empty"

Closes #119205

See merge request gitlab-org/gitlab!22134
parents a5b6245d 67001c4d
---
title: Fix for 500 when error stack trace is empty
merge_request: 119205
author:
type: fixed
......@@ -187,13 +187,13 @@ module Sentry
def parse_stack_trace(event)
exception_entry = event.dig('entries')&.detect { |h| h['type'] == 'exception' }
return unless exception_entry
return [] unless exception_entry
exception_values = exception_entry.dig('data', 'values')
stack_trace_entry = exception_values&.detect { |h| h['stacktrace'].present? }
return unless stack_trace_entry
return [] unless stack_trace_entry
stack_trace_entry.dig('stacktrace', 'frames')
stack_trace_entry.dig('stacktrace', 'frames') || []
end
def map_to_error(issue)
......
{
"eventID": "333b98e3b91341d8a6247edff171d8cf",
"dist": null,
"userReport": null,
"projectID": "1788822",
"previousEventID": "d32f1ce60de14911beec5109d9b5bdbd",
"message": null,
"id": "333b98e3b91341d8a6247edff171d8cf",
"size": 77202,
"errors": [
{
"data": {
"reason": "the cookie is missing a name/value pair",
"name": "request.cookies",
"value": "********"
},
"message": "Discarded invalid value",
"type": "invalid_data"
},
{
"data": {
"reason": "the cookie is missing a name/value pair",
"name": "request.cookies",
"value": "********"
},
"message": "Discarded invalid value",
"type": "invalid_data"
}
],
"culprit": "/",
"title": "ActiveRecord::NoDatabaseError: FATAL: database \"test_development\" does not exist",
"sdkUpdates": [],
"platform": "ruby",
"location": "active_record/connection_adapters/postgresql_adapter.rb",
"nextEventID": null,
"type": "error",
"metadata": {
"function": "rescue in connect",
"type": "ActiveRecord::NoDatabaseError",
"value": "FATAL: database \"test_development\" does not exist\n",
"filename": "active_record/connection_adapters/postgresql_adapter.rb"
},
"groupingConfig": {
"enhancements": "eJybzDhxY3J-bm5-npWRgaGlroGxrpHxBABcTQcY",
"id": "newstyle:2019-05-08"
},
"crashFile": null,
"tags": [
{
"value": "Chrome 78.0.3904",
"key": "browser",
"_meta": null
},
{
"value": "Chrome",
"key": "browser.name",
"_meta": null
},
{
"value": "Mac OS X 10.15.1",
"key": "client_os",
"_meta": null
},
{
"value": "Mac OS X",
"key": "client_os.name",
"_meta": null
},
{
"value": "development",
"key": "environment",
"_meta": null
},
{
"value": "error",
"key": "level",
"_meta": null
},
{
"value": "ruby",
"key": "logger",
"_meta": null
},
{
"value": "b56ae26",
"key": "release",
"_meta": null
},
{
"value": "Seans-MBP.fritz.box",
"key": "server_name",
"_meta": null
},
{
"value": "/",
"key": "transaction",
"_meta": null
},
{
"value": "http://localhost:3001/",
"key": "url",
"_meta": null
},
{
"query": "user.ip:\"::1\"",
"value": "ip:::1",
"key": "user",
"_meta": null
}
],
"dateCreated": "2019-12-08T21:48:07Z",
"dateReceived": "2019-12-08T21:48:08.579417Z",
"user": {
"username": null,
"name": null,
"ip_address": "::1",
"email": null,
"data": null,
"id": null
},
"entries": [],
"packages": {
"coffee-script": "2.4.1",
"uglifier": "4.1.20",
"ffi": "1.11.1",
"actioncable": "5.2.3",
"io-like": "0.3.0",
"rb-inotify": "0.10.0",
"spring": "2.1.0",
"loofah": "2.2.3",
"selenium-webdriver": "3.142.3",
"marcel": "0.3.3",
"sass-listen": "4.0.0",
"nokogiri": "1.10.4",
"activestorage": "5.2.3",
"activejob": "5.2.3",
"mimemagic": "0.3.3",
"faraday": "0.17.1",
"execjs": "2.7.0",
"activesupport": "5.2.3",
"rails-html-sanitizer": "1.2.0",
"byebug": "11.0.1",
"xpath": "3.2.0",
"msgpack": "1.3.1",
"childprocess": "1.0.1",
"rails-dom-testing": "2.0.3",
"public_suffix": "3.1.1",
"mini_mime": "1.0.2",
"arel": "9.0.0",
"coffee-rails": "4.2.2",
"bundler": "1.17.3",
"rails": "5.2.3",
"globalid": "0.4.2",
"sentry-raven": "2.12.3",
"concurrent-ruby": "1.1.5",
"capybara": "3.28.0",
"regexp_parser": "1.6.0",
"sprockets-rails": "3.2.1",
"tzinfo": "1.2.5",
"mail": "2.7.1",
"actionview": "5.2.3",
"rubyzip": "1.2.3",
"coffee-script-source": "1.12.2",
"listen": "3.1.5",
"i18n": "1.6.0",
"erubi": "1.8.0",
"rake": "12.3.3",
"nio4r": "2.4.0",
"activemodel": "5.2.3",
"web-console": "3.7.0",
"ruby_dep": "1.5.0",
"turbolinks": "5.2.0",
"archive-zip": "0.12.0",
"method_source": "0.9.2",
"minitest": "5.11.3",
"puma": "3.12.1",
"sass-rails": "5.1.0",
"chromedriver-helper": "2.1.1",
"sprockets": "3.7.2",
"bindex": "0.8.1",
"actionmailer": "5.2.3",
"rack-test": "1.1.0",
"bootsnap": "1.4.4",
"railties": "5.2.3",
"mini_portile2": "2.4.0",
"crass": "1.0.4",
"websocket-extensions": "0.1.4",
"multipart-post": "2.1.1",
"rb-fsevent": "0.10.3",
"jbuilder": "2.9.1",
"pg": "1.1.4",
"sass": "3.7.4",
"activerecord": "5.2.3",
"builder": "3.2.3",
"spring-watcher-listen": "2.0.1",
"websocket-driver": "0.7.1",
"thor": "0.20.3",
"thread_safe": "0.3.6",
"addressable": "2.6.0",
"prometheus-client-mmap": "0.9.8",
"tilt": "2.0.9",
"actionpack": "5.2.3",
"rack": "2.0.7",
"turbolinks-source": "5.2.0"
},
"sdk": {
"version": "2.12.3",
"name": "raven-ruby"
},
"_meta": {
"user": null,
"context": null,
"entries": {
"1": {
"data": {
"": null,
"cookies": {
"": {
"err": [
[
"invalid_data",
{
"reason": "the cookie is missing a name/value pair"
}
]
],
"val": "********"
}
},
"url": null,
"headers": null,
"env": null,
"query": null,
"data": null,
"method": null
}
}
},
"contexts": null,
"message": null,
"packages": null,
"tags": {},
"sdk": null
},
"contexts": {
"browser": {
"version": "78.0.3904",
"type": "browser",
"name": "Chrome"
},
"client_os": {
"version": "10.15.1",
"type": "os",
"name": "Mac OS X"
}
},
"fingerprints": [
"6aa133ea51857634f2d113de52b5cc61",
"e1613eeb169241eab95b76ab52a80c68"
],
"context": {
"server": {
"runtime": {
"version": "ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]",
"name": "ruby"
},
"os": {
"kernel_version": "Darwin Seans-MBP.fritz.box 19.0.0 Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64 x86_64",
"version": "Darwin Kernel Version 19.0.0: Thu Oct 17 16:17:15 PDT 2019; root:xnu-6153.41.3~29/RELEASE_X86_64",
"build": "19.0.0",
"name": "Darwin"
}
}
},
"release": {
"dateReleased": null,
"commitCount": 0,
"url": null,
"data": {},
"lastDeploy": null,
"deployCount": 0,
"dateCreated": "2019-12-08T21:47:47Z",
"lastEvent": "2019-12-09T21:52:05Z",
"version": "b56ae26",
"firstEvent": "2019-12-08T21:47:47Z",
"lastCommit": null,
"shortVersion": "b56ae26",
"authors": [],
"owner": null,
"newGroups": 26,
"ref": null,
"projects": [
{
"slug": "gitlab-03",
"name": "gitlab-03"
}
]
},
"groupID": "1378364652"
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -218,4 +218,62 @@ describe Sentry::Client do
it_behaves_like 'issues has correct length', 1
end
end
describe '#issue_latest_event' do
let(:sample_response) do
Gitlab::Utils.deep_indifferent_access(
JSON.parse(fixture_file('sentry/issue_latest_event_sample_response.json'))
)
end
let(:issue_id) { '1234' }
let(:sentry_api_response) { sample_response }
let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0' }
let(:sentry_request_url) { sentry_url + "/issues/#{issue_id}/events/latest/" }
let!(:sentry_api_request) { stub_sentry_request(sentry_request_url, body: sentry_api_response) }
subject { client.issue_latest_event(issue_id: issue_id) }
it_behaves_like 'calls sentry api'
it 'has correct return type' do
expect(subject).to be_a(Gitlab::ErrorTracking::ErrorEvent)
end
shared_examples 'assigns error tracking event correctly' do
using RSpec::Parameterized::TableSyntax
where(:event_object, :sentry_response) do
:issue_id | :groupID
:date_received | :dateReceived
end
with_them do
it { expect(subject.public_send(event_object)).to eq(sentry_api_response.dig(*sentry_response)) }
end
end
context 'error object created from sentry response' do
it_behaves_like 'assigns error tracking event correctly'
it 'parses the stack trace' do
expect(subject.stack_trace_entries).to be_a Array
expect(subject.stack_trace_entries).not_to be_empty
end
context 'error without stack trace' do
before do
sample_response['entries'] = []
stub_sentry_request(sentry_request_url, body: sample_response)
end
it_behaves_like 'assigns error tracking event correctly'
it 'returns an empty array for stack_trace_entries' do
expect(subject.stack_trace_entries).to eq []
end
end
end
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