Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

piexif.dump errors are not safely handled #849

Closed
sarayourfriend opened this issue Aug 4, 2022 · 2 comments · Fixed by #932
Closed

piexif.dump errors are not safely handled #849

sarayourfriend opened this issue Aug 4, 2022 · 2 comments · Fixed by #932
Assignees
Labels
🕹 aspect: interface Concerns end-users' experience with the software 🛠 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

Comments

@sarayourfriend
Copy link
Contributor

Sentry link

https://sentry.io/share/issue/a80d52de7f89436586ed0250cd0a32d2/

Description

The call to piexif.dump should be wrapped in a try/except to prevent these errors in the watermark endpoint.

Reproduction

Visit https://api-dev.openverse.engineering/v1/images/a913fde1-d524-4059-bd4f-9bd687578cc3/watermark/ to see an example of this failure.

@sarayourfriend sarayourfriend added good first issue New-contributor friendly help wanted Open to participation from the community 🟨 priority: medium Not blocking but should be addressed soon 🛠 goal: fix Bug fix 🕹 aspect: interface Concerns end-users' experience with the software labels Aug 4, 2022
@AetherUnbound
Copy link
Contributor

Closing this in favor of #827, as both Sentry errors are manifestations of the same issue. I'll also merge the Sentry issues together.

@krysal
Copy link
Member

krysal commented Sep 16, 2022

We're not catching all the exceptions on this code block so reopening.

try:
response = requests.get(url, headers=HEADERS)
img_bytes = BytesIO(response.content)
img = Image.open(img_bytes)
# Preserve EXIF metadata
if "exif" in img.info:
exif = piexif.load(img.info["exif"])
else:
exif = None
return img, exif
except requests.exceptions.RequestException as e:
capture_exception(e)
logger.error(f"Error loading image data: {e}")
return None, None

@krysal krysal reopened this Sep 16, 2022
@krysal krysal self-assigned this Sep 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🕹 aspect: interface Concerns end-users' experience with the software 🛠 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants