Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 5 additions & 4 deletions test-callback-typing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

import sentry_sdk
from sentry_sdk.types import Event, Hint, SamplingContext, Breadcrumb, BreadcrumbHint, MonitorConfig
from sentry_sdk.types import Event, Hint, SamplingContext, Breadcrumb, BreadcrumbHint, MonitorConfig, SpanJSON

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Non-public SpanJSON import fails

Medium Severity

Importing SpanJSON from sentry_sdk.types fails because that name is not on the public types surface. This typing test then never reaches sentry_sdk.init or the span callback.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit eb5dff0. Configure here.

from sentry_sdk.crons import MonitorStatus, capture_checkin


Expand All @@ -22,8 +22,8 @@ def my_before_send(event: Event, hint: Hint) -> Event | None:
return event


def my_before_send_transaction(event: Event, hint: Hint) -> Event | None:
return event
def my_before_send_span(span: SpanJSON, hint: Hint) -> SpanJSON:
return span


def my_before_breadcrumb(crumb: Breadcrumb, hint: BreadcrumbHint) -> Breadcrumb | None:
Expand All @@ -37,14 +37,15 @@ async def main() -> None:
dsn=os.getenv("SENTRY_DSN", None),
environment=os.getenv("ENV", "local"),
traces_sample_rate=1.0,
trace_lifecycle="stream",
profiles_sample_rate=1.0,
send_default_pii=True,
debug=True,
error_sampler=my_error_sampler,
traces_sampler=my_traces_sampler,
profiles_sampler=my_profiles_sampler,
before_send=my_before_send,
before_send_transaction=my_before_send_transaction,
before_send_span=my_before_send_span,
before_breadcrumb=my_before_breadcrumb,
)

Expand Down
2 changes: 1 addition & 1 deletion test-callback-typing/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies = [
"ipdb>=0.13.13",
"mypy>=1.15.0",
"ruff>=0.11.5",
"sentry-sdk",
"sentry-sdk>=2.68.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The sentry-sdk dependency is bumped to >=2.68.1 but the uv.lock file is not updated, pinning an older version. This will cause a runtime crash when using new SDK features.
Severity: CRITICAL

Suggested Fix

Regenerate the lockfile to reflect the new dependency constraints. Run uv lock and uv sync to update uv.lock with a version of sentry-sdk that satisfies the >=2.68.1 requirement. Ensure the local editable path ../../sentry-python points to a compatible version before locking.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: test-callback-typing/pyproject.toml#L10

Potential issue: The `pyproject.toml` file updates the `sentry-sdk` requirement to
`>=2.68.1` to use new features like `trace_lifecycle` and `before_send_span`. However,
the `uv.lock` file was not regenerated and still pins an editable install of
`sentry-sdk` at version `2.26.1`. When the application is executed via `run.sh`, the `uv
run` command will detect the stale lockfile. This version mismatch will cause either a
dependency resolution failure or a `TypeError` at runtime because the new
`sentry_sdk.init()` arguments are not available in the installed version, causing the
application to crash on startup.

Also affects:

  • test-callback-typing/main.py:45~53

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

"typing-extensions>=4.13.2",
]

Expand Down
Loading