-
Notifications
You must be signed in to change notification settings - Fork 572
fix(integrations): Anthropic: add content transformation for images and documents #5276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(integrations): Anthropic: add content transformation for images and documents #5276
Conversation
…ction for tool results
…edact-image-data-messages
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Documentation 📚
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
| # Handle image blocks | ||
| if block_type == "image": | ||
| source = content_block.get("source", {}) | ||
| source_type = source.get("type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Crash when source field is None or non-dict
Medium Severity
The pattern content_block.get("source", {}) followed by source.get("type") can crash if the source key exists but has a None or non-dict value. Python's dict.get(key, default) only returns the default when the key is absent, not when the value is None. If a malformed content block like {"type": "image", "source": None} is passed, source becomes None and the subsequent .get("type") call raises an AttributeError. Since _set_input_data is called outside capture_internal_exceptions, this would crash the user's application.
Description
Handling of non-text request messages
Issues
Closes https://linear.app/getsentry/issue/TET-1636/redact-images-anthropic