rommapp / romm

A beautiful, powerful, self-hosted rom manager
https://romm.app
GNU Affero General Public License v3.0
2.42k stars 100 forks source link

[Bug] Internal Server Error with Custom Cover Image #1191

Open Skeeve opened 2 months ago

Skeeve commented 2 months ago

RomM version

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
rommapp/romm        latest              c1f46b652d32        8 days ago          289MB
mariadb             latest              2af45915db5d        10 days ago         414MB

Describe the bug

Image is not accepted by romm

To Reproduce

Steps to reproduce the behavior:

I wanted to use this image: http://adb.arcadeitalia.net/media/mame.current/titles/ldrun.png?release=208 as custom cover.

Expected behavior

I got an empty error message from romm and below logs

Screenshots

romm       | 192.168.192.20:0 - "PUT /api/roms/3?rename_as_source=false&remove_cover=false&unmatch_metadata=false HTTP/1.0" 500
romm       | INFO:    [nginx][2024-09-13 12:57:40]  192.168.192.20 - - "PUT /api/roms/3?rename_as_source=false&remove_cover=false&unmatch_metadata=false HTTP/1.1" 500 21 "http://kodiwyse.local:6464/rom/3" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36" rt=0.128 uct="0.000" uht="0.127" urt="0.127"
romm       | [2024-09-13 12:57:40 +0000] [23] [ERROR] Exception in ASGI application
romm       |   + Exception Group Traceback (most recent call last):
romm       |   |   File "/src/.venv/lib/python3.12/site-packages/starlette/_utils.py", line 87, in collapse_excgroups
romm       |   |     yield
romm       |   |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 190, in __call__
romm       |   |     async with anyio.create_task_group() as task_group:
romm       |   |   File "/src/.venv/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 680, in __aexit__
romm       |   |     raise BaseExceptionGroup(
romm       |   | ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
romm       |   +-+---------------- 1 ----------------
romm       |     | Traceback (most recent call last):
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
romm       |     |     result = await app(  # type: ignore[func-returns-value]
romm       |     |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
romm       |     |     return await self.app(scope, receive, send)
romm       |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
romm       |     |     await super().__call__(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/applications.py", line 123, in __call__
romm       |     |     await self.middleware_stack(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
romm       |     |     raise exc
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
romm       |     |     await self.app(scope, receive, _send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 189, in __call__
romm       |     |     with collapse_excgroups():
romm       |     |   File "/usr/lib/python3.12/contextlib.py", line 158, in __exit__
romm       |     |     self.gen.throw(value)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/_utils.py", line 93, in collapse_excgroups
romm       |     |     raise exc
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 191, in __call__
romm       |     |     response = await self.dispatch_func(request, call_next)
romm       |     |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/backend/utils/context.py", line 41, in set_context_middleware
romm       |     |     return await call_next(request)
romm       |     |            ^^^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 165, in call_next
romm       |     |     raise app_exc
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 151, in coro
romm       |     |     await self.app(scope, receive_or_disconnect, send_no_error)
romm       |     |   File "/backend/handler/auth/middleware.py", line 146, in __call__
romm       |     |     await self.app(scope, receive, send_wrapper)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/authentication.py", line 48, in __call__
romm       |     |     await self.app(scope, receive, send)
romm       |     |   File "/backend/handler/auth/middleware.py", line 19, in __call__
romm       |     |     await super().__call__(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette_csrf/middleware.py", line 72, in __call__
romm       |     |     await self.app(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 91, in __call__
romm       |     |     await self.simple_response(scope, receive, send, request_headers=headers)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 146, in simple_response
romm       |     |     await self.app(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
romm       |     |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
romm       |     |     raise exc
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
romm       |     |     await app(scope, receive, sender)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 758, in __call__
romm       |     |     await self.middleware_stack(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 778, in app
romm       |     |     await route.handle(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 299, in handle
romm       |     |     await self.app(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 79, in app
romm       |     |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
romm       |     |     raise exc
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
romm       |     |     await app(scope, receive, sender)
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
romm       |     |     response = await func(request)
romm       |     |                ^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 278, in app
romm       |     |     raw_response = await run_endpoint_function(
romm       |     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
romm       |     |     return await dependant.call(**values)
romm       |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/starlette/authentication.py", line 84, in async_wrapper
romm       |     |     return await func(*args, **kwargs)
romm       |     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/backend/endpoints/rom.py", line 453, in update_rom
romm       |     |     fs_resource_handler.resize_cover_to_small(file_location_s)
romm       |     |   File "/backend/handler/filesystem/resources_handler.py", line 38, in resize_cover_to_small
romm       |     |     cover = Image.open(cover_path)
romm       |     |             ^^^^^^^^^^^^^^^^^^^^^^
romm       |     |   File "/src/.venv/lib/python3.12/site-packages/PIL/Image.py", line 3498, in open
romm       |     |     raise UnidentifiedImageError(msg)
romm       |     | PIL.UnidentifiedImageError: cannot identify image file '/romm/resources/roms/14/3/cover/small.png'
romm       |     +------------------------------------
romm       | During handling of the above exception, another exception occurred:
romm       | Traceback (most recent call last):
romm       |   File "/src/.venv/lib/python3.12/site-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
romm       |     result = await app(  # type: ignore[func-returns-value]
romm       |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/src/.venv/lib/python3.12/site-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
romm       |     return await self.app(scope, receive, send)
romm       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/src/.venv/lib/python3.12/site-packages/fastapi/applications.py", line 1054, in __call__
romm       |     await super().__call__(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/applications.py", line 123, in __call__
romm       |     await self.middleware_stack(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 186, in __call__
romm       |     raise exc
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/errors.py", line 164, in __call__
romm       |     await self.app(scope, receive, _send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 189, in __call__
romm       |     with collapse_excgroups():
romm       |   File "/usr/lib/python3.12/contextlib.py", line 158, in __exit__
romm       |     self.gen.throw(value)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/_utils.py", line 93, in collapse_excgroups
romm       |     raise exc
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 191, in __call__
romm       |     response = await self.dispatch_func(request, call_next)
romm       |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/backend/utils/context.py", line 41, in set_context_middleware
romm       |     return await call_next(request)
romm       |            ^^^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 165, in call_next
romm       |     raise app_exc
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/base.py", line 151, in coro
romm       |     await self.app(scope, receive_or_disconnect, send_no_error)
romm       |   File "/backend/handler/auth/middleware.py", line 146, in __call__
romm       |     await self.app(scope, receive, send_wrapper)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/authentication.py", line 48, in __call__
romm       |     await self.app(scope, receive, send)
romm       |   File "/backend/handler/auth/middleware.py", line 19, in __call__
romm       |     await super().__call__(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette_csrf/middleware.py", line 72, in __call__
romm       |     await self.app(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 91, in __call__
romm       |     await self.simple_response(scope, receive, send, request_headers=headers)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/cors.py", line 146, in simple_response
romm       |     await self.app(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
romm       |     await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
romm       |     raise exc
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
romm       |     await app(scope, receive, sender)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 758, in __call__
romm       |     await self.middleware_stack(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 778, in app
romm       |     await route.handle(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 299, in handle
romm       |     await self.app(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 79, in app
romm       |     await wrap_app_handling_exceptions(app, request)(scope, receive, send)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
romm       |     raise exc
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
romm       |     await app(scope, receive, sender)
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/routing.py", line 74, in app
romm       |     response = await func(request)
romm       |                ^^^^^^^^^^^^^^^^^^^
romm       |   File "/src/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 278, in app
romm       |     raw_response = await run_endpoint_function(
romm       |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/src/.venv/lib/python3.12/site-packages/fastapi/routing.py", line 191, in run_endpoint_function
romm       |     return await dependant.call(**values)
romm       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/src/.venv/lib/python3.12/site-packages/starlette/authentication.py", line 84, in async_wrapper
romm       |     return await func(*args, **kwargs)
romm       |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/backend/endpoints/rom.py", line 453, in update_rom
romm       |     fs_resource_handler.resize_cover_to_small(file_location_s)
romm       |   File "/backend/handler/filesystem/resources_handler.py", line 38, in resize_cover_to_small
romm       |     cover = Image.open(cover_path)
romm       |             ^^^^^^^^^^^^^^^^^^^^^^
romm       |   File "/src/.venv/lib/python3.12/site-packages/PIL/Image.py", line 3498, in open
romm       |     raise UnidentifiedImageError(msg)
romm       | PIL.UnidentifiedImageError: cannot identify image file '/romm/resources/roms/14/3/cover/small.png'

Desktop (please complete the following information):

Smartphone (please complete the following information):

not used

adamantike commented 1 month ago

Thanks for reporting this issue! We have found the root cause, and filed a fix in #1238.