Skip to content
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1f32952
fix(ai): redact message parts content of type blob
constantinius Dec 17, 2025
795bcea
fix(ai): skip non dict messages
constantinius Dec 17, 2025
a623e13
fix(ai): typing
constantinius Dec 17, 2025
3d3ce5b
fix(ai): content items may not be dicts
constantinius Dec 17, 2025
433bc88
fix(integrations): google-genai: reworked `gen_ai.request.messages` e…
constantinius Jan 5, 2026
4244319
fix(integrations): address cursor review comments
constantinius Jan 8, 2026
f72aa45
fix(integrations): ensure file_data returns valid blob structure only…
constantinius Jan 8, 2026
2be0419
fix(integrations): add type ignore for missing PIL.Image import
constantinius Jan 8, 2026
4abdcf8
Merge branch 'master' into constantinius/fix/integrations/google-gena…
constantinius Jan 13, 2026
86f6ecb
fix: linting issue and review comment
constantinius Jan 13, 2026
7e9335e
Merge branch 'master' into constantinius/fix/integrations/google-gena…
constantinius Jan 14, 2026
0355c63
fix(integrations): google-genai do not encode binary data that gets r…
constantinius Jan 14, 2026
910c679
fix(integrations): Use explicit None checks instead of `or {}` pattern
constantinius Jan 14, 2026
bd78165
feat(ai): Add shared content transformation functions for multimodal …
constantinius Jan 15, 2026
e7eb226
Merge shared content transformation functions
constantinius Jan 15, 2026
fc6bbfe
refactor(google-genai): Use shared transform_content_part for dict fo…
constantinius Jan 15, 2026
412b93e
refactor(ai): split transform_content_part into SDK-specific functions
constantinius Jan 15, 2026
ff7247b
Merge SDK-specific transform functions
constantinius Jan 15, 2026
b9b629e
refactor(google-genai): use transform_google_content_part directly
constantinius Jan 15, 2026
b80f6e9
test: added comprehensive tests for direct API access with various ki…
constantinius Jan 16, 2026
37b1761
fix: modality and tpe for file references
constantinius Jan 19, 2026
7d825af
fix: wrong modality and type for file references
constantinius Jan 19, 2026
d28e0b8
fix: several small fixes around content parts
constantinius Jan 19, 2026
79b0272
Merge branch 'master' into constantinius/fix/integrations/google-gena…
constantinius Jan 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions sentry_sdk/integrations/google_genai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ def extract_contents_messages(contents: "ContentListUnion") -> "List[Dict[str, A
# File object
file_uri = getattr(contents, "uri", None)
mime_type = getattr(contents, "mime_type", None)
if file_uri and mime_type:
# Process if we have file_uri, even if mime_type is missing
if file_uri is not None:
# Default to empty string if mime_type is None
if mime_type is None:
mime_type = ""

blob_part = {
"type": "uri",
"modality": get_modality_from_mime_type(mime_type),
Expand Down Expand Up @@ -325,7 +330,12 @@ def _extract_part_content(part: "Any") -> "Optional[dict[str, Any]]":
file_data = part.file_data
file_uri = getattr(file_data, "file_uri", None)
mime_type = getattr(file_data, "mime_type", None)
if file_uri and mime_type:
# Process if we have file_uri, even if mime_type is missing (consistent with dict handling)
if file_uri is not None:
# Default to empty string if mime_type is None (consistent with transform_google_content_part)
if mime_type is None:
mime_type = ""

return {
"type": "uri",
"modality": get_modality_from_mime_type(mime_type),
Expand All @@ -338,13 +348,25 @@ def _extract_part_content(part: "Any") -> "Optional[dict[str, Any]]":
inline_data = part.inline_data
data = getattr(inline_data, "data", None)
mime_type = getattr(inline_data, "mime_type", None)
if data and mime_type:
# Process if we have data, even if mime_type is missing/empty (consistent with dict handling)
if data is not None:
# Default to empty string if mime_type is None (consistent with transform_google_content_part)
if mime_type is None:
mime_type = ""

# Handle both bytes (binary data) and str (base64-encoded data)
if isinstance(data, bytes):
return {
"type": "blob",
"mime_type": mime_type,
"content": BLOB_DATA_SUBSTITUTE,
}
content = BLOB_DATA_SUBSTITUTE
else:
# For non-bytes data (e.g., base64 strings), use as-is
content = data

return {
"type": "blob",
"modality": get_modality_from_mime_type(mime_type),
"mime_type": mime_type,
"content": content,
}

return None

Expand Down Expand Up @@ -417,6 +439,7 @@ def _extract_pil_image(image: "Any") -> "Optional[dict[str, Any]]":

return {
"type": "blob",
"modality": get_modality_from_mime_type(mime_type),
"mime_type": mime_type,
"content": BLOB_DATA_SUBSTITUTE,
}
Expand Down
Loading