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

Pinning Flask<2 requires pinning ItsDangerous<2.1 and MarkupSafe<2.1 #4455

Closed
jeehoonkim-youha opened this issue Feb 18, 2022 · 9 comments
Closed

Comments

@jeehoonkim-youha
Copy link

jeehoonkim-youha commented Feb 18, 2022

Since the update of itsdangerous module to version 2.1.0, Flask 1.1.2 fails to run.
This is because Flask’s requirements.txt indicates to install itsdangerous >= 0.24, it automatically installs the newest version which leads to using deprecated feature.
I can do a workaround in my project’s requirements.txt to install itsdangerous <= 2.0.1 before installing Flask but is it possible to fix the requirements.txt in Flask to install itsdangerous not upper than 2.0.1?

To replicate the bug,

  1. install Flask 1.1.2
  2. flask run in terminal
  3. it will produce ImportError: cannot import name 'json' from 'itsdangerous'

Thank you in advance.

Environment:

  • Python version: 3.8
  • Flask version: 1.1.2
@gandalftheFFFFFF
Copy link

gandalftheFFFFFF commented Feb 18, 2022

I just hit this during a deployment with flask version 1.0.2 and python 3.7.9

@fwindolf
Copy link

You can simply fix the requirements from your side to work around the issue until it's fixed.

itsdangerous==1.1.0
markupsafe==1.1.1

@aditya-kar
Copy link

I would recommend moving up to Flask 1.1.4 from 1.1.2. It already has the fix you're looking for.

    install_requires=[
        "Werkzeug >= 0.15, < 2.0",
        "Jinja2 >= 2.10.1, < 3.0",
        "itsdangerous >= 0.24, < 2.0",
        "click >= 5.1, < 8.0",
    ],

@davidism
Copy link
Member

davidism commented Feb 18, 2022

You are using an unsupported version of Flask, 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.

@davidism davidism pinned this issue Feb 18, 2022
@davidism davidism changed the title Flask fails after itsdangerous module’s update Flask<2 fails with ItsDangerous>=2.1, MarkupSafe>=2.1 Feb 18, 2022
@davidism davidism changed the title Flask<2 fails with ItsDangerous>=2.1, MarkupSafe>=2.1 Pinning Flask<2 requires pinning ItsDangerous<2.1 and MarkupSafe<2.1 Feb 18, 2022
RobbeSneyders added a commit to spec-first/connexion that referenced this issue Feb 18, 2022
To prevent a dependency conflict between Flask and itsdangerous.
pallets/flask#4455
@chrisinmtown
Copy link

I would recommend moving up to Flask 1.1.4 from 1.1.2. It already has the fix you're looking for.

I had flask pinned to version 1.1.4, that still yielded this runtime error:

ImportError: cannot import name 'soft_unicode' from 'markupsafe'

In my ignorance and impatience I tried unpinning Flask. Then it jumped up to version 2.0.3 and pip found a solution for all dependencies. HTH

@remoyson
Copy link

You are using an unsupported version of Flask, 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.

@davidism Your remark made me wondering what versions of Flask are still supported officially? Only 2.0.3 then as latest, so Flask does not guarantee any backwards compatibility (or only for patches)? Or how can we see when a version has reached end of life (a bit like everyone knowing python 3.6 was end of life 31 December 2021 cause it is widely announced). F.e. where could we have found that version 1.1.4 has reached end of life? I think this would be useful in future to have a better idea of what versions are supported (and when support will end) and also to plan upfront for upgrading.
Thanks in advance for your insights on this :)

@davidism
Copy link
Member

pallets/markupsafe#286 (comment)

The only supported version is the latest version (currently 2.0.x, but 2.1.x will be released in the next week or two) which receives bug fixes. The development version (main) receives features and merges in bug fixes, but it's not "supported" since it's not a stable release. This is true for all the Pallets projects, and is the typical implicit policy of most open source projects unless otherwise noted. https://bernat.tech/posts/version-numbers/#whats-the-problem-with-semantic-versioning discusses some of the reasons why this is.

@BenDavisson
Copy link

If you have a dependency on an older version of Flask like myself, I found a solution by following this answer given by @fwindolf.

My versions:

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

ahnitz added a commit to ahnitz/pegasus that referenced this issue Feb 21, 2022
The latest release of markupsafe has exposed a side-effect of pinning dependencies on flask, whose old versions also require an old version of jinja2. The old version of jinja2 breaks with the latest markupsafe. This means that at the moment, pegasus-wms can't be installed with pip and used as intended. The most recent version of markupsafe will be installed and thus break. 

See also pallets/flask#4455
@woodgiraffe
Copy link

pallets/markupsafe#286 (comment)

The only supported version is the latest version (currently 2.0.x, but 2.1.x will be released in the next week or two) which receives bug fixes. The development version (main) receives features and merges in bug fixes, but it's not "supported" since it's not a stable release. This is true for all the Pallets projects, and is the typical implicit policy of most open source projects unless otherwise noted. https://bernat.tech/posts/version-numbers/#whats-the-problem-with-semantic-versioning discusses some of the reasons why this is.

Thanks for the info on this and thanks for your work on the project! I fully agree with the article that you linked and it also seems to me that pallets never specified that the projects follow semver to begin with, so while understandable that one would mistake these version to strictly follow semver, that's a bit of a hasty judgement and so it seems important, I think, to highlight that pallets project don't follow strict semver at all and never made any promises to do so.

I would recommend to update and if not possible, the latest version of itsdangerous that is compatible with <2 Flask is 2.0.1, so I'd recommend trying this version first.

Cheers.

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

9 participants