YunoHost-Apps / synapse_ynh

Matrix server (synapse) package for YunoHost
https://matrix.org/
GNU General Public License v3.0
79 stars 43 forks source link

AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' #396

Open jukefr opened 11 months ago

jukefr commented 11 months ago

Describe the bug

AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

Suspecting the wrong version of Pillow is getting installed for some reason. Here you can see new version https://github.com/YunoHost-Apps/synapse_ynh/commit/1c36215f03e5bc1b4c22ec42f93e6188f73a9f36#diff-1268f00633c5bf56c0f92e476d2d15adfd7dcebba9c727f8e8cffcdbeeb041a7L29 which deprecates ANTILIAS function however for some reason the running synapse version seems to depend on a call to it? Not sure if this is a bug in upstream synapse or if something wrong with the selected dependency version in the ynh wrapper for some reason.

Context

Steps to reproduce

Expected behavior

The version of pillow should either be supported by the codebase (so under 10) or the codebase should be recent enough to support pillow 10? Not exactly sure what went wrong again if upstream or wrapper dependency version got set wrong for some resaon.

Logs

  - Jul 12 21:55:01 python[1822]: 2023-07-12 21:55:01,187 - synapse.http.server - 133 - ERROR - POST-23998- Failed handle request via 'UploadResource': <XForwardedForRequest at 0x7f65e41970 method='POST' uri='/_matrix/media/r0/upload?filename=IMG_7786.png' clientproto='HTTP/1.0' site='8008'>
  - Jul 12 21:55:01 python[1822]: Traceback (most recent call last):
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/http/server.py", line 319, in _async_render_wrapper
  - Jul 12 21:55:01 python[1822]:     callback_return = await self._async_render(request)
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/http/server.py", line 349, in _async_render
  - Jul 12 21:55:01 python[1822]:     callback_return = await raw_callback_return
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/rest/media/upload_resource.py", line 95, in _async_render_POST
  - Jul 12 21:55:01 python[1822]:     content_uri = await self.media_repo.create_content(
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/media/media_repository.py", line 215, in create_content
  - Jul 12 21:55:01 python[1822]:     await self._generate_thumbnails(None, media_id, media_id, media_type)
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/media/media_repository.py", line 797, in _generate_thumbnails
  - Jul 12 21:55:01 python[1822]:     t_byte_source = await defer_to_thread(
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/twisted/python/threadpool.py", line 244, in inContext
  - Jul 12 21:55:01 python[1822]:     result = inContext.theWork()  # type: ignore[attr-defined]
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/twisted/python/threadpool.py", line 260, in <lambda>
  - Jul 12 21:55:01 python[1822]:     inContext.theWork = lambda: context.call(  # type: ignore[attr-defined]
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/twisted/python/context.py", line 117, in callWithContext
  - Jul 12 21:55:01 python[1822]:     return self.currentContext().callWithContext(ctx, func, *args, **kw)
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/twisted/python/context.py", line 82, in callWithContext
  - Jul 12 21:55:01 python[1822]:     return func(*args, **kw)
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/logging/context.py", line 969, in g
  - Jul 12 21:55:01 python[1822]:     return f(*args, **kwargs)
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/media/thumbnailer.py", line 172, in crop
  - Jul 12 21:55:01 python[1822]:     with self._resize(scaled_width, scaled_height) as scaled_image:
  - Jul 12 21:55:01 python[1822]:   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/media/thumbnailer.py", line 134, in _resize
  - Jul 12 21:55:01 python[1822]:     return self.image.resize((width, height), Image.ANTIALIAS)
  - Jul 12 21:55:01 python[1822]: AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'
Josue-T commented 11 months ago

Hello, It's an upstream issue which will be fixed on the next release. For now you can fix the issue by this command:

/opt/yunohost/matrix-synapse/bin/pip install 'Pillow<=9.5.0-2'
systemctl restart matrix-synapse.service