Skip to content

Commit 684cd6f

Browse files
ericapisaniclaude
andcommitted
fix(pydantic-ai): Convert ImageUrl.url to string before regex match
In Pydantic v2, ImageUrl.url is a Url object, not a string. Passing it directly to re.match() raises TypeError at runtime. Convert to string first, then reuse for both the regex match and the return value. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 592b100 commit 684cd6f

File tree

1 file changed

+4
-3
lines changed
  • sentry_sdk/integrations/pydantic_ai/spans

1 file changed

+4
-3
lines changed

sentry_sdk/integrations/pydantic_ai/spans/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ def _serialize_image_url_item(item: "Any") -> "Dict[str, Any]":
2020
For data URLs containing base64-encoded images, the content is redacted.
2121
For regular HTTP URLs, the URL string is preserved.
2222
"""
23-
data_url_matches = DATA_URL_BASE64_REGEX.match(item.url)
23+
url = str(item.url)
24+
data_url_match = DATA_URL_BASE64_REGEX.match(url)
2425

25-
if data_url_matches:
26+
if data_url_match:
2627
return {
2728
"type": "image",
2829
"content": BLOB_DATA_SUBSTITUTE,
2930
}
3031

3132
return {
3233
"type": "image",
33-
"content": str(item.url),
34+
"content": url,
3435
}
3536

3637

0 commit comments

Comments
 (0)