-
Notifications
You must be signed in to change notification settings - Fork 50
Description
The following exception will currently fire when attempts to download media using this module are made against Synapse v1.140.0rc1 or higher.
2025-10-01 13:40:14,853 - twisted - 278 - CRITICAL - sentinel - Unhandled Error
Traceback (most recent call last):
File "/home/user/.virtualenvs/synapse311/lib/python3.11/site-packages/twisted/python/threadpool.py", line 269, in inContext
result = inContext.theWork() # type: ignore[attr-defined]
File "/home/user/.virtualenvs/synapse311/lib/python3.11/site-packages/twisted/python/threadpool.py", line 285, in <lambda>
inContext.theWork = lambda: context.call( # type: ignore[attr-defined]
File "/home/user/.virtualenvs/synapse311/lib/python3.11/site-packages/twisted/python/context.py", line 117, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/home/user/.virtualenvs/synapse311/lib/python3.11/site-packages/twisted/python/context.py", line 82, in callWithContext
return func(*args, **kw)
File "/home/user/.virtualenvs/synapse311/lib/python3.11/site-packages/s3_storage_provider.py", line 143, in _get_file
s3_download_task(
File "/home/user/.virtualenvs/synapse311/lib/python3.11/site-packages/s3_storage_provider.py", line 206, in s3_download_task
with LoggingContext(parent_context=parent_logcontext):
builtins.TypeError: LoggingContext.__init__() missing 2 required keyword-only arguments: 'name' and 'server_name'
This is due to this PR: element-hq/synapse#18868, which requires a server_name
parameter be passed to LoggingContext
. This is actually the fault of this module for import LoggingContext
directly from within Synapse, rather than using ModuleApi.run_as_background_process
instead. This also isn't the first time this module has broken due to an internal Synapse change related to LoggingContext
:
synapse-s3-storage-provider/s3_storage_provider.py
Lines 35 to 39 in 002149d
# Synapse 1.13.0 moved current_context to a module-level function. | |
try: | |
from synapse.logging.context import current_context | |
except ImportError: | |
current_context = LoggingContext.current_context |
As Synapse v1.140.0rc1 has not been released yet, it seems best to modify LoggingContext
to have a default value for server_name
. This would stop the breakage of badly behaving modules. Edit: done in element-hq/synapse#19003.
In the meantime, this module should be updated to no longer rely on an internal import of LoggingContext
.