Skip to content

Commit b2d4400

Browse files
fix: Handle invalid SENTRY_DEBUG values properly (#4400)
Previously, if the environment variable `SENTRY_DEBUG` would have an invalid value, such as "invalid," we would set `rv["debug"]` to `None`. However, since this value should be a boolean, it should instead be set to `False`. This change ensures that `rv["debug"]` always is a boolean. Where we previously would have set the value to `None`, we now set it to `False`. Other behavior remains unchanged. Ref https://github.com/getsentry/sentry-python/pull/4366/files#r2075294825
1 parent 9261b2c commit b2d4400

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

sentry_sdk/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def _get_options(*args, **kwargs):
110110
rv["environment"] = os.environ.get("SENTRY_ENVIRONMENT") or "production"
111111

112112
if rv["debug"] is None:
113-
rv["debug"] = env_to_bool(os.environ.get("SENTRY_DEBUG", "False"), strict=True)
113+
rv["debug"] = env_to_bool(os.environ.get("SENTRY_DEBUG"), strict=True) or False
114114

115115
if rv["server_name"] is None and hasattr(socket, "gethostname"):
116116
rv["server_name"] = socket.gethostname()

0 commit comments

Comments
 (0)