-
Notifications
You must be signed in to change notification settings - Fork 572
fix(integrations): google-genai: reworked gen_ai.request.messages extraction from parameters
#5275
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): google-genai: reworked gen_ai.request.messages extraction from parameters
#5275
Conversation
… if mime_type and file_uri are present (Cursor comment)
…i-report-image-inputs
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 🔧Release
Other
🤖 This preview updates automatically when you update the PR. |
…i-report-image-inputs
| if isinstance(function_response, dict): | ||
| tool_call_id = function_response.get("id") | ||
| tool_name = function_response.get("name") | ||
| response_dict = function_response.get("response") or {} | ||
| # Prefer "output" key if present, otherwise use entire response | ||
| output = response_dict.get("output", response_dict) | ||
| else: | ||
| # FunctionResponse object | ||
| tool_call_id = getattr(function_response, "id", None) | ||
| tool_name = getattr(function_response, "name", None) | ||
| response_obj = getattr(function_response, "response", None) or {} |
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.
I've seen this .get() vs getattr pattern a lot in our AI integrations. Feels like introducing a helper function that would try both at once would potentially deduplicate a lot of code.
Not something that needs to be done in this PR, mostly thinking out loud.
| assert blob_part["type"] == "blob" | ||
| assert blob_part["mime_type"].startswith("image/") | ||
| assert "content" in blob_part | ||
| assert blob_part["content"].startswith("data:image/") |
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.
Test expects data URL but code returns placeholder
Medium Severity
The test test_extract_contents_messages_pil_image asserts that blob_part["content"].startswith("data:image/"), but the _extract_pil_image function returns BLOB_DATA_SUBSTITUTE which is defined as "[Blob substitute]". This assertion will fail when the test runs (when PIL is available and genai_types.PIL_Image exists).
Description
Previously we only extracted only text parts were extracted. Now the full range of possibilities are covered.
Issues
Closes https://linear.app/getsentry/issue/TET-1638/redact-images-google-genai