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

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jul 5, 2026
  2. added
    agentsUsage: [Issues, PRs], Target: Single agent
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions