Skip to content

fix(pydantic-ai): Only use hooks when ModelRequestContext.model exists - #6480

Merged
alexander-alderman-webb merged 8 commits into
masterfrom
webb/pydantic-ai/hooks-version-gate
Jun 2, 2026
Merged

fix(pydantic-ai): Only use hooks when ModelRequestContext.model exists#6480
alexander-alderman-webb merged 8 commits into
masterfrom
webb/pydantic-ai/hooks-version-gate

Conversation

@alexander-alderman-webb

@alexander-alderman-webb alexander-alderman-webb commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

Prevent

AttributeError: 'ModelRequestContext' object has no attribute 'model'

raised, e.g., with version 1.71.0 of Pydantic AI in the generated test suite of #6437

Issues

Reminders

@alexander-alderman-webb
alexander-alderman-webb requested a review from a team as a code owner June 2, 2026 07:56
Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py Outdated
Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py Outdated
Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py
@alexander-alderman-webb
alexander-alderman-webb marked this pull request as draft June 2, 2026 08:04
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

88053 passed | ⏭️ 6009 skipped | Total: 94062 | Pass Rate: 93.61% | Execution Time: 295m 34s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 72.22%. Project has 2311 uncovered lines.
✅ Project coverage is 89.97%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/pydantic_ai/init.py 68.75% ⚠️ 5 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.96%    89.97%    +0.01%
==========================================
  Files          191       191         —
  Lines        23031     23040        +9
  Branches      7906      7908        +2
==========================================
+ Hits         20719     20729       +10
- Misses        2312      2311        -1
- Partials      1306      1308        +2

Generated by Codecov Action

@alexander-alderman-webb
alexander-alderman-webb marked this pull request as ready for review June 2, 2026 08:16
Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py
Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py
Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 96f45fa. Configure here.

Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py
Comment thread sentry_sdk/integrations/pydantic_ai/__init__.py
@alexander-alderman-webb alexander-alderman-webb changed the title fix(pydantic-ai): Only use hooks when ModelRequestContext.model is available Jun 2, 2026
@alexander-alderman-webb
alexander-alderman-webb merged commit fbaf664 into master Jun 2, 2026
267 of 272 checks passed
@alexander-alderman-webb
alexander-alderman-webb deleted the webb/pydantic-ai/hooks-version-gate branch June 2, 2026 08:53
mgaligniana pushed a commit to mgaligniana/sentry-python that referenced this pull request Aug 9, 2026
…sts (getsentry#6480)

Avoid `AttributeError` when `ModelRequestContext` does not expose the newer `model` field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants