Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions sentry_sdk/integrations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from threading import Lock
import sys

from sentry_sdk.utils import logger

Expand Down Expand Up @@ -74,6 +75,11 @@ def iter_default_integrations(
"sentry_sdk.integrations.threading.ThreadingIntegration",
]

if sys.version_info >= (3, 8):
_DEFAULT_INTEGRATIONS.append(
"sentry_sdk.integrations.unraisablehook.UnraisablehookIntegration"
)
Comment on lines +79 to +81
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential bug: Adding a non-existent integration causes an unhandled `ModuleNotFoundError` in `iter_default_integrations`, crashing applications during `sentry_sdk.init()`.
  • Description: The iter_default_integrations function attempts to import sentry_sdk.integrations.unraisablehook.UnraisablehookIntegration, which does not exist in the codebase. This action triggers a ModuleNotFoundError. The try...except block within the function is not configured to catch this specific exception, as it only handles DidNotEnable and SyntaxError. As a result, the unhandled ModuleNotFoundError will propagate up the call stack during SDK initialization (sentry_sdk.init()), causing any application using the SDK with default settings to crash on startup.

  • Suggested fix: Add ModuleNotFoundError to the except clause in the iter_default_integrations function. This will ensure that attempting to load a non-existent integration is gracefully handled by logging a debug message and continuing, which matches the intended behavior for other integration loading failures.
    severity: 0.9, confidence: 0.98

Did we get this right? 👍 / 👎 to inform future reviews.


_AUTO_ENABLING_INTEGRATIONS = [
"sentry_sdk.integrations.aiohttp.AioHttpIntegration",
"sentry_sdk.integrations.anthropic.AnthropicIntegration",
Expand Down
Loading