Skip to content

Image type used for thumbnails is sometimes incorrectly extracted from the content type #3750

Closed

Description

Description

Reproduction

  1. Go to https://api.openverse.engineering/v1/images/cf168b67-00be-4e4c-8985-ccf388afecd5/thumb
  2. You should get a 415 error, the media type is not supported, with the following detail:
{"detail":"Unsupported media type \"Image extension png;charset=UTF-8 is not supported by the thumbnail proxy.\" in request."}

The image is a png, but extracting it from the head request is done incorrectly, and instead of png we get png;charset=UTF-8

Additional context

def _get_file_extension_from_content_type(content_type: str) -> str | None:
"""
Return the image extension if present in the Response's content type
header.
"""
if content_type and "/" in content_type:
return content_type.split("/")[1]

Adding a .split(";")[0] could probably fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Labels

Type

No type

Projects

  • Status

    ✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions