LibrePhotos / librephotos

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

Backend throws exception for some videos, "file not found" #1276

Open HMKnapp opened 4 months ago

HMKnapp commented 4 months ago

🐛 Bug Report

📝 Description of issue:

Backend crashes after video upload is complete.

proxy           | 192.168.0.190 - - [18/May/2024:22:47:25 +0000] "POST /api/upload/ HTTP/1.1" 200 109 "-" "UhuruPhotos/0.0.220 Dalvik/2.1.0 (Linux; U; Android 10; Nokia 7 plus Build/QKQ1.190828.002)"
backend         | Internal Server Error: /api/upload/complete/
backend         | Traceback (most recent call last):
backend         |   File "/code/api/models/file.py", line 73, in is_video
backend         |     filename = mime.from_file(path)
backend         |   File "/usr/local/lib/python3.10/dist-packages/magic/__init__.py", line 112, in from_file
backend         |     with _real_open(filename):
backend         | FileNotFoundError: [Errno 2] No such file or directory: ''
backend         | 
backend         | During handling of the above exception, another exception occurred:
backend         | 
backend         | Traceback (most recent call last):
backend         |   File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/exception.py", line 55, in inner
backend         |     response = get_response(request)
backend         |   File "/usr/local/lib/python3.10/dist-packages/django/core/handlers/base.py", line 197, in _get_response
backend         |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
backend         |   File "/usr/local/lib/python3.10/dist-packages/django/views/generic/base.py", line 104, in view
backend         |     return self.dispatch(request, *args, **kwargs)
backend         |   File "/usr/local/lib/python3.10/dist-packages/django/utils/decorators.py", line 46, in _wrapper
backend         |     return bound_method(*args, **kwargs)
backend         |   File "/usr/local/lib/python3.10/dist-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
backend         |     return view_func(*args, **kwargs)
backend         |   File "/usr/local/lib/python3.10/dist-packages/django/views/generic/base.py", line 143, in dispatch
backend         |     return handler(request, *args, **kwargs)
backend         |   File "/usr/local/lib/python3.10/dist-packages/chunked_upload/views.py", line 100, in post
backend         |     return self._post(request, *args, **kwargs)
backend         |   File "/usr/local/lib/python3.10/dist-packages/chunked_upload/views.py", line 288, in _post
backend         |     self.on_completion(chunked_upload.get_uploaded_file(), request)
backend         |   File "/code/api/views/upload.py", line 144, in on_completion
backend         |     create_new_image(user, photo_path)
backend         |   File "/code/api/directory_watcher.py", line 82, in create_new_image
backend         |     if not is_valid_media(path):
backend         |   File "/code/api/models/file.py", line 133, in is_valid_media
backend         |     if is_video(path) or is_raw(path) or is_metadata(path):
backend         |   File "/code/api/models/file.py", line 77, in is_video
backend         |     raise False
backend         | TypeError: exceptions must derive from BaseException
proxy           | 192.168.0.190 - - [18/May/2024:22:47:26 +0000] "POST /api/upload/complete/ HTTP/1.1" 500 145 "-" "UhuruPhotos/0.0.220 Dalvik/2.1.0 (Linux; U; Android 10; Nokia 7 plus Build/QKQ1.190828.002)"

The video in question exists on the server. The same exception happens with other videos from the same phone as well. (This could be an issue with Uhuru Photos, not necessarily with librephotos apart from the unhandled exception.)

🔁 How can we reproduce it:

I can send you the video if you like.

Please provide additional information:

pnaskardev commented 2 months ago

Hi things I need

  1. API logs before the error
  2. Video clip of the error