Skip to content

Python: malformed data_uri should not leak IndexError #6917

Description

@VectorPeak

detect_media_type_from_base64(data_uri=...) currently indexes the result of splitting on ;base64, before validating that the delimiter exists.

Malformed or non-base64 data URI inputs can therefore leak an implementation-level IndexError instead of the documented ValueError contract for invalid caller input.

Example inputs:

detect_media_type_from_base64(data_uri="data:text/plain,hello")
detect_media_type_from_base64(data_uri="data:image/png;base64")
detect_media_type_from_base64(data_uri="not-a-data-uri")

Expected behavior: invalid data_uri shapes fail with a clear ValueError rather than IndexError.

Related PR: #6916

Metadata

Metadata

Assignees

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: Python

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions