Skip to content

Fix #263: make sentry_sdk import optional (clean-install ModuleNotFoundError) - #271

Open
Diogo-Damasceno wants to merge 1 commit into
confident-ai:mainfrom
Diogo-Damasceno:fix/optional-sentry-sdk
Open

Fix #263: make sentry_sdk import optional (clean-install ModuleNotFoundError)#271
Diogo-Damasceno wants to merge 1 commit into
confident-ai:mainfrom
Diogo-Damasceno:fix/optional-sentry-sdk

Conversation

@Diogo-Damasceno

Copy link
Copy Markdown

Summary

Fixes #263ModuleNotFoundError: No module named 'sentry_sdk' on a clean install.

deepteam/telemetry.py imported sentry_sdk unconditionally at module top level. On a clean pip install deepteam where sentry-sdk was not on the path, that single import raised ModuleNotFoundError and broke every import of deepteam.telemetry (and thus the package).

Changes

  • Wrap the sentry_sdk import in try/except and alias it to None when missing — matching the pattern already used for opentelemetry/posthog.
  • Guard sentry_sdk.init(...) and sentry_sdk.capture_exception(...) on the optional alias so the module degrades gracefully instead of crashing.
  • Declare sentry-sdk, posthog and the opentelemetry-* packages as direct dependencies in pyproject.toml. They were only present in poetry.lock, so a fresh install could end up without them.

Verification

Note: this does not change telemetry behaviour when sentry_sdk is present; it only removes the hard dependency that made the package unimportable without it.

…ModuleNotFoundError)

telemetry.py imported sentry_sdk unconditionally at module top level, so a
clean  without sentry-sdk on the path raised
ModuleNotFoundError on every import of deepteam.telemetry (issue confident-ai#263).

- Wrap the sentry_sdk import in try/except and alias it to None when missing
  (matching the existing pattern used for opentelemetry/posthog).
- Guard sentry_sdk.init(...) and sentry_sdk.capture_exception(...) on the
  optional alias so the module degrades gracefully instead of crashing.
- Declare sentry-sdk, posthog and the opentelemetry packages as direct
  dependencies in pyproject.toml (they were only present in poetry.lock, so
  a fresh install could end up without them).

Verified: tests/unit/test_telemetry_optional_sentry.py passes (2 passed). The
test loads telemetry.py with sentry_sdk blocked and asserts the module imports
without error; it fails against the old unconditional import, confirming the
regression is covered.
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

@Diogo-Damasceno is attempting to deploy a commit to the Confident AI Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModuleNotFoundError: No module named 'sentry_sdk' on a clean install of deepteam 1.0.9

1 participant