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

Template fails to render due to ZeroDivisionError when input is corrupted #596

Open
bixbyr opened this issue Jan 29, 2022 · 0 comments
Open

Comments

@bixbyr
Copy link

bixbyr commented Jan 29, 2022

I accidentally ingested some bad images which are invalid data. Instead of failing silently as per normal, I end up with an uncaught exception when I try to render my page due to a ZeroDivisionError. This is very disruptive, and seems to go against the stated goal of the package to fail silently. Could I request error handling when source_x or source_y is zero?

  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/django/template/base.py", line 1038, in render
    output = self.filter_expression.resolve(context)
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/django/template/base.py", line 728, in resolve
    new_obj = func(obj, *arg_vals)
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/easy_thumbnails/templatetags/thumbnail.py", line 301, in thumbnail_url
    raise e
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/easy_thumbnails/templatetags/thumbnail.py", line 298, in thumbnail_url
    thumb = get_thumbnailer(source)[alias]
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/easy_thumbnails/files.py", line 344, in __getitem__
    return self.get_thumbnail(options, silent_template_exception=True)
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/easy_thumbnails/files.py", line 508, in get_thumbnail
    thumbnail = self.generate_thumbnail(
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/easy_thumbnails/files.py", line 389, in generate_thumbnail
    thumbnail_image = engine.process_image(image, thumbnail_options,
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/easy_thumbnails/engine.py", line 35, in process_image
    image = processor(image, **processor_options)
  File "/Users/bixbyr/anaconda3/envs/Shelterware_v2/lib/python3.8/site-packages/easy_thumbnails/processors.py", line 179, in scale_and_crop
    scale = min(target_x / source_x, target_y / source_y)
ZeroDivisionError: float division by zero
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant