Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twisted has a new version which causes failure #17882

Open
phreed opened this issue Oct 28, 2024 · 6 comments
Open

Twisted has a new version which causes failure #17882

phreed opened this issue Oct 28, 2024 · 6 comments

Comments

@phreed
Copy link

phreed commented Oct 28, 2024

Description

I just started getting this error.

This is due to an update to Twisted from v24.7.0 to v24.10.0 .
Forcing the older version pip install --force-reinstall -v "Twisted==24.7.0" and that corrected the error.
Apparently, _canonicalHeaderName = Headers()._encodeName is no longer valid.

Steps to reproduce

mkdir ~/synapse
python3.12 -m venv ~/synapse/env
source ~/synapse/env/bin/activate

pip install --upgrade pip
pip install --upgrade setuptools
pip install matrix-synapse
cd  ~/synapse
python -m synapse.app.homeserver --server-name matrix.mcp.mil --config-path homeserver.yaml --generate-config

Homeserver

generating a new homeserver.yaml

Synapse Version

1.117.0

Installation Method

pip (from PyPI)

Database

sqlite

Workers

Single process

Platform

Ubuntu 24
fedora 40

Configuration

No response

Relevant log output

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
 ...
    from synapse.http.site import SynapseRequest
  File "/var/home/me/synapse/env/lib64/python3.12/site-packages/synapse/http/site.py", line 39, in <module>
    from synapse.http.proxy import ProxySite
  File "/var/home/me/synapse/env/lib64/python3.12/site-packages/synapse/http/proxy.py", line 72, in <module>
    _canonicalHeaderName = Headers()._encodeName
                           ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Headers' object has no attribute '_encodeName'

Anything else that would be useful to know?

I updated the synapse/http/proxy.py about line 74 to gain some insight.
While this is not a fix, it may be useful.

 if hasattr(Headers, "_canonicalNameCaps"):
    logger.warning(f'you appear to be running an old version of Twisted < 24.7.0')
    _canonicalHeaderName = Headers()._canonicalNameCaps  # type: ignore[attr-defined]
elif hasattr(Headers, "_encodeName"):
    logger.warning(f'you appear to be running an old version of Twisted 24.7.0')
    # But note that `_encodeName` still exists on prior versions,
    # it just encodes differently
    _canonicalHeaderName = Headers()._encodeName
else:
    logger.warning(f'you appear to be at an unsupported version of Twisted')
    _canonicalHeaderName = 'foo.name'
@phreed
Copy link
Author

phreed commented Oct 29, 2024

As you can see _encodeName was part of the private API.
https://docs.twisted.org/en/twisted-24.7.0/api/twisted.web.http_headers.Headers.html?private=1

It is removed in the 24.10.0
https://docs.twisted.org/en/twisted-24.10.0/api/twisted.web.http_headers.Headers.html?private=1

I think the intent is to use the str function instead.

@villepeh
Copy link
Contributor

Can confirm the issue. I downgraded Twisted and Synapse works again.

@dillfrescott
Copy link

dillfrescott commented Oct 29, 2024

Running into this issue as well, prevents synapse from starting. (Synapse 1.118.0)

@dillfrescott
Copy link

Can confirm downgrading to the last version of Twisted remedies the issue

@Josue-T
Copy link

Josue-T commented Oct 30, 2024

Same issue on my side, downgrade also fixed the issue.

@arkamar
Copy link
Contributor

arkamar commented Oct 30, 2024

It is currently also related to #17075.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants