Skip to content

Conversation

@constantinius
Copy link
Contributor

Description

Add more support on message types for gen_ai.request.messages

Issues

Closes: https://linear.app/getsentry/issue/TET-1637/redact-images-langchain

@constantinius constantinius requested a review from a team as a code owner January 5, 2026 19:16
@linear
Copy link

linear bot commented Jan 5, 2026

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

github-actions bot commented Jan 13, 2026

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(grpc): Derive interception state from channel fields by alexander-alderman-webb in #5302
  • fix(integrations): langchain add multimodal content transformation functions for images, audio, and files by constantinius in #5278
  • 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(metrics): Remove experimental notice by alexander-alderman-webb in #5304
  • docs: Update Python versions banner in README by sentrivana in #5287

Internal Changes 🔧

Release

  • ci(release): Bump Craft version to fix issues by BYK in #5305
  • ci(release): Switch from action-prepare-release to Craft by BYK in #5290

Other

  • chore(gen_ai): add auto-enablement for google genai by shellmayr in #5295
  • ci: Update tox and handle generic classifiers by sentrivana in #5306

🤖 This preview updates automatically when you update the PR.

"file_id": content_block.get("file_id", ""),
}

# Handle legacy image_url format (OpenAI style)
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb Jan 14, 2026

Choose a reason for hiding this comment

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

langchain supports providing content in a provider-native format.

So, I'm wondering whether we are deliberately only handling langchain-standard blocks and OpenAI-formatted blocks?

See https://docs.langchain.com/oss/python/langchain/messages#message-content

Comment on lines +189 to +190
header, content = url.split(",", 1)
mime_type = header.split(":")[1].split(";")[0] if ":" in header else ""
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm worried about inconsistencies in the URI decoding across different AI integrations. Can this be centralized?

"modality": "image",
"mime_type": file_data.get("mime_type", ""),
"uri": file_data.get("file_uri", ""),
}
Copy link

Choose a reason for hiding this comment

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

Google-style formats ignore block type, hardcode "image" modality

Medium Severity

When a content block has a standard type like "audio", "video", or "file" but stores its data using Google's inline_data or file_data format (instead of base64, url, file_id, or source), the function falls through the standard type handler without returning. It then hits the Google-style handlers which hardcode modality to "image", discarding the correctly computed modality. For example, {"type": "audio", "inline_data": {"mime_type": "audio/mp3", "data": "..."}} would incorrectly get modality: "image" instead of "audio".

Fix in Cursor Fix in Web

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.

3 participants