Skip to content

fix(pydantic_ai): stop setting transaction status on AI span errors#5865

Closed
NIK-TIGER-BILL wants to merge 1 commit intogetsentry:masterfrom
NIK-TIGER-BILL:fix/pydantic-ai-stop-setting-transaction-status
Closed

fix(pydantic_ai): stop setting transaction status on AI span errors#5865
NIK-TIGER-BILL wants to merge 1 commit intogetsentry:masterfrom
NIK-TIGER-BILL:fix/pydantic-ai-stop-setting-transaction-status

Conversation

@NIK-TIGER-BILL
Copy link

Description

AI integrations should not interfere with HTTP transactions.

_capture_exception() in pydantic_ai/utils.py called set_span_errored() which propagated INTERNAL_ERROR to the containing HTTP transaction. Replace with get_current_span() + direct span.set_status(SPANSTATUS.INTERNAL_ERROR) that only affects the AI span.

Changed files:

  • sentry_sdk/integrations/pydantic_ai/utils.pyset_span_errored replaced with direct span status

Note: the existing test_error_handling already asserts trace_status != "error", which is consistent with this fix.

Issues

AI integrations should not interfere with HTTP transactions.
Replace set_span_errored() with direct span.set_status() to avoid
propagating INTERNAL_ERROR to the containing HTTP transaction.

Fixes getsentry#5795

Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pydantic-ai: Stop setting transaction status

2 participants