LibrePhotos / librephotos

A self-hosted open source photo management service. This is the repository of the backend.
MIT License
7.01k stars 309 forks source link

backend exception IndexError: Cannot choose from an empty sequence #240

Closed rickysarraf closed 3 years ago

rickysarraf commented 3 years ago

🐛 Bug Report

What Operating system and version is LibrePhotos running on:

Debian Docker based LibrePhotos setup

What architecture is LibrePhotos running on:

x64

How is LibrePhotos installed:

Docker

If running via Docker or Kubernetes please list version including docker-compose:

3.8

Are you running LibrePhotos on a virtual machine if so please list:

No

How is you picture library mounted on the host (or in the virtual machine):

Local file system BTRFS and EXT4

Description of issue:

Ran into following exception

proxy_1     | 172.21.0.1 - - [25/Apr/2021:09:34:26 +0000] "GET /api/albums/place/list/ HTTP/1.1" 200 113201 "http://lenovo:3000/recent" "Mozilla/backend_1   | Internal Server Error: /api/searchtermexamples/
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
backend_1   |   File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
backend_1   |     return self.dispatch(request, *args, **kwargs)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
backend_1   |     response = self.handle_exception(exc)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
backend_1   |     self.raise_uncaught_exception(exc)
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
backend_1   |     raise exc
backend_1   |   File "/usr/local/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
backend_1   |     response = handler(request, *args, **kwargs)
backend_1   |   File "/code/api/views.py", line 1363, in get
backend_1   |     search_term_examples = get_search_term_examples(request.user)
backend_1   |   File "/code/api/api_util.py", line 163, in get_search_term_examples
backend_1   |     term_thing = random.choice(datum['things'])
backend_1   |   File "/usr/local/lib/python3.8/random.py", line 290, in choice
backend_1   |     raise IndexError('Cannot choose from an empty sequence') from None
backend_1   | IndexError: Cannot choose from an empty sequence
proxy_1     | 172.21.0.1 - - [25/Apr/2021:09:34:26 +0000] "GET /api/searchtermexamples/ HTTP/1.1" 500 145 "http://lenovo:3000/recent" "Mozilla/5.

How can we reproduce it:

It think, the problem is this: image

You'll notice from the screenshot above, that not all thumbnail items are displayed by LibrePhotos. I don't know why. But the placeholder is there. So is the link as I was able to extract it through the browser. http://lenovo:3000/media/square_thumbnails/9018ed907116f0d2487bbe2302bdf9aa1.jpg

I believe that, when a user clicks on an thumbnail placeholder which does not render a thumbnail, an exception is generated.

praul commented 3 years ago

I get the same error and also a completely blank page with this inspector error: image

derneuere commented 3 years ago

I resolved the issue.