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

AttributeError: module 'jinja2' has no attribute 'Markup' #304

Closed
matthias4217 opened this issue Mar 25, 2022 · 24 comments
Closed

AttributeError: module 'jinja2' has no attribute 'Markup' #304

matthias4217 opened this issue Mar 25, 2022 · 24 comments

Comments

@matthias4217
Copy link

Describe the bug

Synapse upgrade or backup restore fails because of a AttributeError: module 'jinja2' has no attribute 'Markup' error.
It seems that this has been removed from the very recent new Jinja version : https://jinja.palletsprojects.com/en/3.1.x/changes/?highlight=markup#version-3-1-0 I suppose this may be more of an upstream Synapse issue though, but I figure it's worth mentioning here too.

Context

  • Hardware: VPS bought online
  • YunoHost version: 4.3.6.2
  • I have access to my server: I have a SSH access, but tried these via the webadmin
  • Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: yes
    • My server has some "non-yunohost" use, and as such, has several other softwares installed, including docker.
  • Using, or trying to install package version/branch: Synapse 1.47.1
  • If upgrading, current package version: Synapse 1.46.0~ynh1

Steps to reproduce

  • Try upgrading Synapse, after having done a system upgrade

Expected behavior

No fail during the upgrade, and no fail during the restore

Logs

Logs from the restoration are here : https://paste.yunohost.org/raw/wabaxagujo

@hieronymousch
Copy link

Can confirm this bug running Debian Buster when upgrading from Synapse 1.51 to 1.55. Backup restore failed as well...

@joelselvaraj
Copy link

joelselvaraj commented Mar 27, 2022

The jinja2 package had a new release (3.1.0) on Mar 24 which breaks matrix and prevents it from starting. Probably because of the changes to Markup. You can check the changelog here: https://jinja.palletsprojects.com/en/3.1.x/changes/
"Markup and escape should be imported from MarkupSafe." should probably be the issue. It will hopefully be fixed in the synapse side in the upcoming versions. Here's the error for reference:

2022-03-27 05:45:52,697: WARNING - 770851 Here's an extract of the logs before the crash. It might help debugging the error:
2022-03-27 05:45:52,698: DEBUG - 770851 DEBUG - Mar 27 05:45:50 python[10740]:   File "/opt/yunohost/matrix-synapse/lib/python3.7/site-packages/synapse/events/spamcheck.py", line 31, in <module>
2022-03-27 05:45:52,698: DEBUG - 770851 DEBUG - Mar 27 05:45:50 python[10740]:     from synapse.rest.media.v1._base import FileInfo
2022-03-27 05:45:52,698: DEBUG - 770851 DEBUG - Mar 27 05:45:50 python[10740]:   File "/opt/yunohost/matrix-synapse/lib/python3.7/site-packages/synapse/rest/__init__.py", line 17, in <module>
2022-03-27 05:45:52,698: DEBUG - 770851 DEBUG - Mar 27 05:45:50 python[10740]:     from synapse.rest.client import (
2022-03-27 05:45:52,698: DEBUG - 770851 DEBUG - Mar 27 05:45:50 python[10740]:   File "/opt/yunohost/matrix-synapse/lib/python3.7/site-packages/synapse/rest/client/account.py", line 39, in <module>
2022-03-27 05:45:52,699: DEBUG - 770852 DEBUG - Mar 27 05:45:50 python[10740]:     from synapse.push.mailer import Mailer
2022-03-27 05:45:52,699: DEBUG - 770852 DEBUG - Mar 27 05:45:50 python[10740]:   File "/opt/yunohost/matrix-synapse/lib/python3.7/site-packages/synapse/push/mailer.py", line 838, in <module>
2022-03-27 05:45:52,699: DEBUG - 770852 DEBUG - Mar 27 05:45:50 python[10740]:     def safe_markup(raw_html: str) -> jinja2.Markup:
2022-03-27 05:45:52,699: DEBUG - 770852 DEBUG - Mar 27 05:45:50 python[10740]: AttributeError: module '\''jinja2'\'' has no attribute '\''Markup'\''
2022-03-27 05:45:52,699: DEBUG - 770852 DEBUG - Mar 27 05:45:50 systemd[1]: matrix-synapse.service: Control process exited, code=exited, status=1/FAILURE
2022-03-27 05:45:52,699: DEBUG - 770852 DEBUG - Mar 27 05:45:50 systemd[1]: matrix-synapse.service: Failed with result '\''exit-code'\''.
2022-03-27 05:45:52,699: DEBUG - 770852 DEBUG - Mar 27 05:45:50 systemd[1]: Failed to start Synapse Matrix homeserver.'
2022-03-27 05:45:52,700: DEBUG - 770852 DEBUG - + '[' -e /var/log/matrix-synapse/homeserver.log ']'

This also breaks the restoring backup functionality. I had to manually activate the virtualenv by running source /opt/yunohost/matrix-synapse/bin/activate and downgrade the package (pip3 install jinja2==3.0.1) mid restoration (after the "Check for source up to date..." step is completed and moved on to next step) to temporarily fix the issue.

This will also affect master branch release upgrades if users haven't upgraded before Mar 24.

For now maybe specifying the version here for jinja2 could fix the issues for users trying to upgrade in the near future. https://github.com/YunoHost-Apps/synapse_ynh/blob/master/scripts/_common.sh#L51

@Tagadda
Copy link
Member

Tagadda commented Mar 28, 2022

The bug seems to be fixed upstream matrix-org/synapse#12292 in v1.51.1.

@rantnar
Copy link

rantnar commented Mar 29, 2022

Same problem here on yunohost based on debian bullseye. Can't install synapse.

@joelselvaraj
Copy link

@Josue-T Sorry for the ping. Just wanted to let you know. This is breaking even master branch upgrades and restoring feature too.

@collector-ynh
Copy link

It is still impossible to install synapse from Yunohost

@zunami
Copy link

zunami commented Mar 31, 2022

i hab the same problem
Yunohost 11.0.6


2022-03-31 12:40:59,789: DEBUG - + python -m synapse.app.homeserver --keys-directory /etc/matrix-synapse/ --generate-config --generate-keys --server-name maindomain.tld --report-stats=no -c homeserver.yml
2022-03-31 12:40:59,789: INFO - [################....] > Creating synapse config...
2022-03-31 12:41:00,439: WARNING - Traceback (most recent call last):
2022-03-31 12:41:00,439: WARNING -   File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
2022-03-31 12:41:00,439: WARNING -     return _run_code(code, main_globals, None,
2022-03-31 12:41:00,440: WARNING -   File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
2022-03-31 12:41:00,440: WARNING -     exec(code, run_globals)
2022-03-31 12:41:00,440: WARNING -   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/app/homeserver.py", line 37, in <module>
2022-03-31 12:41:00,440: WARNING -     from synapse.app import _base
2022-03-31 12:41:00,441: WARNING -   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/app/_base.py", line 44, in <module>
2022-03-31 12:41:00,441: WARNING -     from synapse.events.spamcheck import load_legacy_spam_checkers
2022-03-31 12:41:00,441: WARNING -   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/events/spamcheck.py", line 31, in <module>
2022-03-31 12:41:00,441: WARNING -     from synapse.rest.media.v1._base import FileInfo
2022-03-31 12:41:00,441: WARNING -   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/rest/__init__.py", line 19, in <module>
2022-03-31 12:41:00,442: WARNING -     from synapse.rest.client import (
2022-03-31 12:41:00,442: WARNING -   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/rest/client/account.py", line 42, in <module>
2022-03-31 12:41:00,442: WARNING -     from synapse.push.mailer import Mailer
2022-03-31 12:41:00,442: WARNING -   File "/opt/yunohost/matrix-synapse/lib/python3.9/site-packages/synapse/push/mailer.py", line 860, in <module>
2022-03-31 12:41:00,443: WARNING -     def safe_markup(raw_html: str) -> jinja2.Markup:
2022-03-31 12:41:00,443: WARNING - AttributeError: module 'jinja2' has no attribute 'Markup'
2022-03-31 12:41:00,506: DEBUG - + ynh_exit_properly
2022-03-31 12:41:01,009: DEBUG - + ynh_clean_setup
2022-03-31 12:41:01,009: DEBUG - + ynh_clean_check_starting
2022-03-31 12:41:01,009: DEBUG - + '[' -n '' ']'
2022-03-31 12:41:01,009: DEBUG - + '[' -n '' ']'
2022-03-31 12:41:02,010: ERROR - Unable to install synapse: An error occurred inside the app installation script

@Nalla22
Copy link

Nalla22 commented Mar 31, 2022

I am also experiencing the same problem since yesterday, unable to install Synapse server.
How to solve this problem?

@trentwiles
Copy link

Getting the same issue here too. When will there be a fix?

@Nalla22
Copy link

Nalla22 commented Apr 5, 2022

Getting the same issue here too. When will there be a fix?

I've been waiting for two weeks for a solution that still doesn't happen.

@trentwiles
Copy link

This is also breaking Rocket.chat's setup script

@Marvin-34
Copy link

Please quickly find a solution to this bug, it has been fixed here matrix-org/synapse#12292

Is there a solution to solve the problem?

@Tagadda
Copy link
Member

Tagadda commented Apr 8, 2022

This should be fixed on the testing branch. You can give it a try with the instructions at the end of the README.

@matthias4217
Copy link
Author

Sorry if I'm a bit out of the topic, but I'm wondering if it is easy to switch back from testing to the stable releases ?

@Tagadda
Copy link
Member

Tagadda commented Apr 8, 2022

Yes, when a newer version will release on stable, you'll be able to upgrade as usual.

@Marvin-34
Copy link

If I install synapse from the test branch, will I still receive the updates once the stable branch is updated?

@Tagadda
Copy link
Member

Tagadda commented Apr 8, 2022

@Marvin-34 Please read the message above yours.

@collector-ynh
Copy link

This should be fixed on the testing branch. You can give it a try with the instructions at the end of the README.

The testing branch works but it is incomplete, because usually I install the following branch : #301 who adds support for /_synapse, can you merge the two?

@lapineige
Copy link
Member

Same issue while trying to upgrade to the latest master version... And I can't restore the backup.

@lapineige
Copy link
Member

lapineige commented May 30, 2022

This also breaks the restoring backup functionality. I had to manually activate the virtualenv by running source /opt/yunohost/matrix-synapse/bin/activate and downgrade the package (pip3 install jinja2==3.0.1) mid restoration (after the "Check for source up to date..." step is completed and moved on to next step) to temporarily fix the issue.

This does solve the restoration issue. Thanks a lot @joelselvaraj ! 🎉

@lapineige
Copy link
Member

But I does not allow to upgrade right away after restoring correctly.
I am not able to upgrade from 1.47 to 1.59.0. I will try to run the same command during the upgrade.

@Bugsbane
Copy link

Bugsbane commented Jun 9, 2022

Mine reports version 1.59.0-ynh1 but I still have the issue and Synapse doesn't respond to any of my clients. I don't see any synapse service to restart in the ynh web admin. Logs: https://paste.yunohost.org/raw/utoxesatez

Any advice?

@Josue-T Josue-T closed this as completed Jul 3, 2022
@Bugsbane
Copy link

Bugsbane commented Jul 4, 2022

Now this is closed as completed, should it require any manual fix beyond the usual package upgrades?

@Josue-T
Copy link

Josue-T commented Jul 5, 2022

I think no.

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