◐ Shell
clean mode source ↗

fix(utils): handle image_url string shorthand in _is_image_type_with_blob_content by devteamaegis · Pull Request #6478 · getsentry/sentry-python

Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: sentry_sdk/ai/utils.py#L614-L617

Potential issue: The expression `(image_url_val or "")` does not properly handle all
types. If `image_url_val` is a truthy value that is not a string or a dictionary (e.g.,
a list or an integer), the expression will return the original object. Subsequently,
`DATA_URL_BASE64_REGEX.match()` is called with this non-string object, which raises a
`TypeError: expected string or bytes-like object`. While this requires malformed input,
the function does not perform type validation, making it vulnerable to data from
user-constructed messages or buggy integrations.