Skip to content

Commit 592b100

Browse files
ericapisaniclaude
andcommitted
ref(pydantic-ai): Remove mime_type from ImageUrl span data and consolidate tests
Remove the mime_type field from ImageUrl serialization in spans since it is not needed for the base64 redaction use case. Update the regex to use non-capturing groups accordingly. Consolidate scattered image URL tests into two parameterized test functions. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e7623d1 commit 592b100

File tree

3 files changed

+95
-325
lines changed

3 files changed

+95
-325
lines changed

sentry_sdk/integrations/pydantic_ai/consts.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
SPAN_ORIGIN = "auto.ai.pydantic_ai"
44

55
# Matches data URLs with base64-encoded content, e.g. "data:image/png;base64,iVBORw0K..."
6-
# Group 1: MIME type (e.g. "image/png"), Group 2: base64 data
76
DATA_URL_BASE64_REGEX = re.compile(
8-
r"^data:([a-zA-Z0-9][a-zA-Z0-9.+\-]*/[a-zA-Z0-9][a-zA-Z0-9.+\-]*)(?:;[a-zA-Z0-9\-]+=[^;,]*)*;base64,([A-Za-z0-9+/\-_]+={0,2})$"
7+
r"^data:(?:[a-zA-Z0-9][a-zA-Z0-9.+\-]*/[a-zA-Z0-9][a-zA-Z0-9.+\-]*)(?:;[a-zA-Z0-9\-]+=[^;,]*)*;base64,(?:[A-Za-z0-9+/\-_]+={0,2})$"
98
)

sentry_sdk/integrations/pydantic_ai/spans/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ def _serialize_image_url_item(item: "Any") -> "Dict[str, Any]":
2323
data_url_matches = DATA_URL_BASE64_REGEX.match(item.url)
2424

2525
if data_url_matches:
26-
mime_type = data_url_matches[1] or "image"
2726
return {
2827
"type": "image",
29-
"mime_type": mime_type,
3028
"content": BLOB_DATA_SUBSTITUTE,
3129
}
3230

0 commit comments

Comments
 (0)