Commit bb6706cd authored by Peter Leitzen's avatar Peter Leitzen

Error Tracking: Support exceptions from Python's repl

In those cases `context_line` is `null` so we should relax the JSON
schema in this case.

Changelog: fixed
parent b580dde8
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
"type": "array" "type": "array"
}, },
"context_line": { "context_line": {
"type": "string" "type": ["string", "null"]
}, },
"post_context": { "post_context": {
"type": "array" "type": "array"
......
{"breadcrumbs":{"values":[]},"contexts":{"runtime":{"build":"3.9.5 (default, May 12 2021, 15:36:59) \n[GCC 8.3.0]","name":"CPython","version":"3.9.5"}},"environment":"production","event_id":"","exception":{"values":[{"mechanism":null,"module":null,"stacktrace":{"frames":[{"abs_path":"/srv/autodevops/<stdin>","context_line":null,"filename":"<stdin>","function":"<module>","in_app":true,"lineno":2,"module":"__main__","post_context":[],"pre_context":[],"vars":{"__annotations__":{},"__builtins__":"<module 'builtins' (built-in)>","__doc__":"None","__loader__":"<class '_frozen_importlib.BuiltinImporter'>","__name__":"'__main__'","__package__":"None","__spec__":"None","capture_exception":"<function capture_exception at 0x7f5dbb3eb940>","e":"ZeroDivisionError('division by zero')","init":"<function _init at 0x7f5dbb3ea1f0>"}}]},"type":"ZeroDivisionError","value":"division by zero"}]},"extra":{"sys.argv":[""]},"level":"error","modules":{"appdirs":"1.4.4","apscheduler":"3.7.0","asgiref":"3.3.4","beautifulsoup4":"4.9.3","certifi":"2020.12.5","chardet":"4.0.0","django":"3.2.3","django-anymail":"1.3","django-environ":"0.4.5","django-livereload-server":"0.3.2","django-widget-tweaks":"1.4.8","fcache":"0.4.7","idna":"2.10","mmh3":"3.0.0","pip":"21.1.2","psycopg2-binary":"2.8.6","pytz":"2021.1","requests":"2.25.1","sentry-sdk":"1.5.0","setuptools":"57.0.0","six":"1.16.0","soupsieve":"2.2.1","sqlparse":"0.4.1","tornado":"6.1","tzlocal":"2.1","unleashclient":"4.2.0","urllib3":"1.26.4","uwsgi":"2.0.19.1","wheel":"0.36.2"},"platform":"python","sdk":{"integrations":["argv","atexit","dedupe","django","excepthook","logging","modules","stdlib","threading","tornado"],"name":"sentry.python","packages":[{"name":"pypi:sentry-sdk","version":"1.5.0"}],"version":"1.5.0"},"server_name":"","timestamp":"2021-11-17T14:46:20.898210Z"}
...@@ -3,16 +3,18 @@ ...@@ -3,16 +3,18 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe ErrorTracking::Collector::PayloadValidator do RSpec.describe ErrorTracking::Collector::PayloadValidator do
let(:validator) { described_class.new }
describe '#valid?' do describe '#valid?' do
RSpec.shared_examples 'valid payload' do RSpec.shared_examples 'valid payload' do
it 'returns true' do specify do
expect(described_class.new.valid?(payload)).to be_truthy expect(validator).to be_valid(payload)
end end
end end
RSpec.shared_examples 'invalid payload' do RSpec.shared_examples 'invalid payload' do
it 'returns false' do specify do
expect(described_class.new.valid?(payload)).to be_falsey expect(validator).not_to be_valid(payload)
end end
end end
...@@ -28,6 +30,12 @@ RSpec.describe ErrorTracking::Collector::PayloadValidator do ...@@ -28,6 +30,12 @@ RSpec.describe ErrorTracking::Collector::PayloadValidator do
it_behaves_like 'valid payload' it_behaves_like 'valid payload'
end end
context 'python payload in repl' do
let(:payload) { Gitlab::Json.parse(fixture_file('error_tracking/python_event_repl.json')) }
it_behaves_like 'valid payload'
end
context 'browser payload' do context 'browser payload' do
let(:payload) { Gitlab::Json.parse(fixture_file('error_tracking/browser_event.json')) } let(:payload) { Gitlab::Json.parse(fixture_file('error_tracking/browser_event.json')) }
......
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