Skip to content

Conversation

@constantinius
Copy link
Contributor

@constantinius constantinius requested a review from a team as a code owner December 17, 2025 14:14
@linear
Copy link

linear bot commented Dec 17, 2025

Base automatically changed from constantinius/fix/redact-message-parts-type-blob to master January 13, 2026 09:56
@github-actions
Copy link
Contributor

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • feat(asyncio): Add on-demand way to enable AsyncioIntegration by sentrivana in #5288

Bug Fixes 🐛

  • fix(ai): redact message parts content of type blob by constantinius in #5243
  • fix(clickhouse): Guard against module shadowing by alexander-alderman-webb in #5250
  • fix(gql): Revert signature change of patched gql.Client.execute by alexander-alderman-webb in #5289
  • fix(integrations): pydantic-ai: properly format binary input message parts to be conformant with the gen_ai.request.messages structure by constantinius in #5251
  • fix(litellm): Guard against module shadowing by alexander-alderman-webb in #5249
  • fix(pure-eval): Guard against module shadowing by alexander-alderman-webb in #5252
  • fix(ray): Guard against module shadowing by alexander-alderman-webb in #5254
  • fix(threading): Handle channels shadowing by sentrivana in #5299
  • fix(typer): Guard against module shadowing by alexander-alderman-webb in #5253

Documentation 📚

  • docs: Update Python versions banner in README by sentrivana in #5287

Internal Changes 🔧

  • ci(release): Switch from action-prepare-release to Craft by BYK in #5290

🤖 This preview updates automatically when you update the PR.

Comment on lines +145 to +147
messages_data = truncate_and_annotate_messages(
normalized_messages, span, scope
)
Copy link

Choose a reason for hiding this comment

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

Bug: The Pydantic AI integration unconditionally redacts binary message content, ignoring the send_default_pii setting and preventing users from seeing this data in traces.
Severity: HIGH

🔍 Detailed Analysis

In the Pydantic AI integration, the function truncate_and_annotate_messages is called to process AI messages. This function unconditionally calls redact_blob_message_parts, which replaces any binary blob content with the string "[Blob substitute]". This redaction occurs regardless of the user's send_default_pii setting. As a result, users who have enabled PII (send_default_pii=True) to view binary content in their traces will find it redacted, which contradicts the intended behavior and the implementation pattern seen in the OpenAI integration, where a should_send_default_pii() check is performed.

💡 Suggested Fix

Wrap the call to truncate_and_annotate_messages within a conditional that checks should_send_default_pii(). This will align the Pydantic AI integration's behavior with the existing OpenAI integration, ensuring binary content is only redacted when PII is disabled.

🤖 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: sentry_sdk/integrations/pydantic_ai/spans/ai_client.py#L145-L147

Potential issue: In the Pydantic AI integration, the function
`truncate_and_annotate_messages` is called to process AI messages. This function
unconditionally calls `redact_blob_message_parts`, which replaces any binary blob
content with the string `"[Blob substitute]"`. This redaction occurs regardless of the
user's `send_default_pii` setting. As a result, users who have enabled PII
(`send_default_pii=True`) to view binary content in their traces will find it redacted,
which contradicts the intended behavior and the implementation pattern seen in the
OpenAI integration, where a `should_send_default_pii()` check is performed.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8534615

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.

2 participants