sentry-python
sentry-python copied to clipboard
Bottle 404 causes internal error
How do you use Sentry?
Sentry Saas (sentry.io)
Version
latest
Steps to Reproduce
Run the following python script.
from bottle import route, run, template
import sentry_sdk
sentry_sdk.init(
dsn="<dsn here>",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
debug=True,
)
@route('/hello/<name>')
def index(name):
1/0
return template('<b>Hello {{name}}</b>!', name=name)
run(host='localhost', port=8080)
Then, navigate to an invalid URL in the browser, e.g. http://localhost:8080/asdf, in order to manually trigger a 404.
Expected Result
No internal error in Sentry SDK
Actual Result
Traceback (most recent call last):
File "/Users/dszoke/Development/SDK/sentry-python/sentry_sdk/scope.py", line 1425, in run_event_processors
new_event = event_processor(event, hint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/dszoke/Development/SDK/sentry-python/sentry_sdk/integrations/bottle.py", line 189, in event_processor
_set_transaction_name_and_source(event, integration.transaction_style, request)
File "/Users/dszoke/Development/SDK/sentry-python/sentry_sdk/integrations/bottle.py", line 175, in _set_transaction_name_and_source
request.route.name
^^^^^^^^^^^^^
File "/Users/dszoke/Development/test-bottle/.venv/lib/python3.12/site-packages/bottle.py", line 213, in __get__
if key not in storage: storage[key] = self.getter(obj)
^^^^^^^^^^^^^^^^
File "/Users/dszoke/Development/test-bottle/.venv/lib/python3.12/site-packages/bottle.py", line 1180, in route
raise RuntimeError('This request is not connected to a route.')
RuntimeError: This request is not connected to a route.