Commit 26612aa8 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

fix: Exception: Make sure value is set for sentry payload

parent e89cb1ab
......@@ -229,7 +229,8 @@ def _init_sentry(self, endpoint: str) -> None:
default_integrations=False,
shutdown_timeout=0,
auto_session_tracking=False,
before_send=self._before_send)
before_send=self._before_send,
debug=False)
sentry_sdk.set_context('os', {
'name': get_os_name(),
......@@ -247,6 +248,16 @@ def _capture_exception(self) -> None:
sentry_sdk.capture_exception(self._traceback_data)
def _before_send(self, event: dict[str, Any], hint: Any) -> dict[str, Any]:
# Make sure the exception value is set, GitLab needs it.
# The value is the arg which is passed to the Exception.
# e.g. raise Exception('Error')
try:
value = event['exception']['values'][0].get('value')
if not value:
event['exception']['values'][0]['value'] = 'Unknown'
except Exception:
pass
# Remove the hostname of the machine
event['server_name'] = ''
pprint.pprint(event)
......
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