fix(pydantic-ai): Only use hooks when ModelRequestContext.model exists#6480
Merged
alexander-alderman-webb merged 8 commits intoJun 2, 2026
Merged
@sentry/warden / warden: code-review
completed
Jun 2, 2026 in 1m 34s
1 issue
code-review: Found 1 issue (1 medium)
Medium
Version guard bypassed when `package_version` returns `None`, re-exposing the AttributeError - `sentry_sdk/integrations/pydantic_ai/__init__.py:168-175`
When package_version("pydantic-ai") returns None (e.g., missing package metadata), the version check short-circuits and the code falls through to register_hooks(hooks), which calls request_context.model — the exact attribute access the PR intends to gate behind >= 1.73. Consider treating a None version as if it is below the minimum safe version, or defaulting are_request_hooks_available to False in that case.
⏱ 1m 13s · 52.3k in / 3.7k out · $0.22
Annotations
Check warning on line 175 in sentry_sdk/integrations/pydantic_ai/__init__.py
sentry-warden / warden: code-review
Version guard bypassed when `package_version` returns `None`, re-exposing the AttributeError
When `package_version("pydantic-ai")` returns `None` (e.g., missing package metadata), the version check short-circuits and the code falls through to `register_hooks(hooks)`, which calls `request_context.model` — the exact attribute access the PR intends to gate behind `>= 1.73`. Consider treating a `None` version as if it is below the minimum safe version, or defaulting `are_request_hooks_available` to `False` in that case.
Loading