Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
obulat opened this issue Feb 5, 2024 · 1 comment · Fixed by #4062
Closed
Assignees
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix good first issue New-contributor friendly help wanted Open to participation from the community 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: api Related to the Django API

Comments

@obulat
Copy link
Contributor

obulat commented Feb 5, 2024

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.

@obulat obulat added help wanted Open to participation from the community 🟨 priority: medium Not blocking but should be addressed soon 🛠 goal: fix Bug fix 💻 aspect: code Concerns the software code in the repository 🧱 stack: api Related to the Django API labels Feb 5, 2024
@obulat obulat added the good first issue New-contributor friendly label Apr 3, 2024
@thegreendrinker
Copy link
Contributor

Darien is working on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix good first issue New-contributor friendly help wanted Open to participation from the community 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: api Related to the Django API
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants