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

Breaking change in markupsafe makes flask crash on service startup #4456

Closed
abrisan opened this issue Feb 18, 2022 · 3 comments
Closed

Breaking change in markupsafe makes flask crash on service startup #4456

abrisan opened this issue Feb 18, 2022 · 3 comments

Comments

@abrisan
Copy link

abrisan commented Feb 18, 2022

This issue in markupsafe is transitively included in flask, so even applications running Flask 1.1.4 are crashing on startup.

Here is a sample stack trace:

Traceback (most recent call last):
  File "/<...>/bin/superset", line 33, in <module>
    sys.exit(load_entry_point('apache-superset==1.4.1', 'console_scripts', 'superset')())
  File "/opt/bb/bin/superset", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/<...>/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/<...>/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/<...>/lib/python3.9/site-packages/superset/__init__.py", line 18, in <module>
    from flask import current_app, Flask
  File "/<...>/lib/python3.9/site-packages/flask/__init__.py", line 14, in <module>
    from jinja2 import escape
  File "/<...>/lib/python3.9/site-packages/jinja2/__init__.py", line 12, in <module>
    from .environment import Environment
  File "/<...>/lib/python3.9/site-packages/jinja2/environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "/<...>/lib/python3.9/site-packages/jinja2/defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "/<...>/lib/python3.9/site-packages/jinja2/filters.py", line 13, in <module>
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/<...>/lib/python3.9/site-packages/markupsafe/__init__.py)

Environment:

  • Python version: 3.9
  • Flask version: 1.1.4
@davidism
Copy link
Member

davidism commented Feb 18, 2022

Duplicate of #4455

You are using an unsupported version of Flask and Jinja, please update to the latest version. Additionally, please read https://hynek.me/articles/semver-will-not-save-you/, then use a tool like pip-tools to pin your dependencies and control when you get updates. Be sure to run your tests with deprecation warnings treated as errors so that you get notified of these types of changes early.

vimalloc added a commit to vimalloc/flask-jwt-extended that referenced this issue Feb 18, 2022
Flask is no longer maintaining the 1.x.x branch, and has in fact broken
it with pallets/flask#4456. Since just
installing flask 1.1.4 is no longer sufficient to run our specs and
insure compatibility, I've opted to follow suite and only support flask
2 going forward.

If flask does decide to do further maintenance on 1.1.5 I will consider
reverting this PR and doing whatever updates we need to in order to
insure that they type checking isn't broken.
vimalloc added a commit to vimalloc/flask-jwt-extended that referenced this issue Feb 18, 2022
* Fix mypy error

This should allow us to add a CI check for type checking going forward

* Drop flask1 support

Flask is no longer maintaining the 1.x.x branch, and has in fact broken
it with pallets/flask#4456. Since just
installing flask 1.1.4 is no longer sufficient to run our specs and
insure compatibility, I've opted to follow suite and only support flask
2 going forward.

If flask does decide to do further maintenance on 1.1.5 I will consider
reverting this PR and doing whatever updates we need to in order to
insure that they type checking isn't broken.

* Fix type checking imports for python < 3.8
@kochb

This comment was marked as off-topic.

wmfgerrit pushed a commit to wikimedia/cloud-toolforge-jobs-framework-api that referenced this issue Feb 21, 2022
This patch prevents this problem:

*** Operational MODE: single process ***
mounting api:app on /
Traceback (most recent call last):
  File "./api.py", line 17, in <module>
    from flask import Flask
  File "/usr/local/lib/python3.7/dist-packages/flask/__init__.py", line 19, in <module>
    from . import json
  File "/usr/local/lib/python3.7/dist-packages/flask/json/__init__.py", line 15, in <module>
    from itsdangerous import json as _json
ImportError: cannot import name 'json' from 'itsdangerous' (/usr/local/lib/python3.7/dist-packages/itsdangerous/__init__.py)
unable to load app 0 (mountpoint='/') (callable not found or import error)

See for reference:

* https://serverfault.com/questions/1094062/error-from-itsdangerous-import-json-as-json-importerror-cannot-import-name-j
* pallets/flask#4456

Signed-off-by: Arturo Borrero Gonzalez <[email protected]>
Change-Id: Ia5f4001a438b95d25c791f5efaa5170c16665547
@BenDavisson
Copy link

If you have a dependency on an older version of Flask like myself, I found a solution by following #4455 (comment) given by @fwindolf.

My versions:

- flask=1.1.4
- itsdangerous==1.1.0
- markupsafe==1.1.1

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants