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

flask-restx is not compatible with the latest werkzeug #460

Closed
12rambau opened this issue Jul 24, 2022 · 14 comments
Closed

flask-restx is not compatible with the latest werkzeug #460

12rambau opened this issue Jul 24, 2022 · 14 comments
Labels
bug Something isn't working

Comments

@12rambau
Copy link

the 2.2.0 release of pallets/werkzeug breaks flask-restx.

Here you can find the following traceback:

../../.local/lib/python3.8/site-packages/flask_restx/__init__.py:5: in <module>
    from .api import Api  # noqa
../../.local/lib/python3.8/site-packages/flask_restx/api.py:50: in <module>
    from .swagger import Swagger
../../.local/lib/python3.8/site-packages/flask_restx/swagger.py:18: in <module>
    from werkzeug.routing import parse_rule
E   ImportError: cannot import name 'parse_rule' from 'werkzeug.routing' (/home/prambaud/.local/lib/python3.8/site-packages/werkzeug/routing/__init__.py)

Repro Steps (if applicable)

  1. install flas-restx
  2. import flask-restx.swagger as frs
  3. Broken!
@bbnil
Copy link

bbnil commented Jul 25, 2022

parse_rule() is marked as :internal:, shouldn't be used by flask-restx
https://github.com/pallets/werkzeug/blob/2.1.x/src/werkzeug/routing.py#L215

@marcszy91
Copy link

I can confirm the bug

@j4asper
Copy link

j4asper commented Jul 25, 2022

Can also confirm the bug.
Quick workaround is to downgrade Flask to v2.1.2, since the newest version requires Werkzeug >= 2.2.0 and Flask v2.1.2 just requires Werkzeug>=2.0
To prevent the flask requirement from getting the newest version of Werkzeug, it should be listed first in the requirements.txt file. Hope that solves someones issue.

Werkzeug <= 2.1.2   
flask == 2.1.2   
flask-restx >= 0.5.1  

@peter-doggart
Copy link
Contributor

There is also an issue with flask-restx and werkzeug 2.1.x (#422) so I would maybe recommend setting werkzeug==2.0.* for now.

xavier-rbz added a commit to xavier-rbz/curiefense that referenced this issue Jul 27, 2022
xavier-rbz added a commit to xavier-rbz/curiefense that referenced this issue Jul 27, 2022
plowman added a commit to plowman/flask-restx that referenced this issue Jul 28, 2022
This method was removed from the public API in werkzeug 2.2.0. Copying it into this project because the method is self-contained.
plowman added a commit to plowman/flask-restx that referenced this issue Jul 28, 2022
This method was removed from the public API in werkzeug 2.2.0. Copying it into this project because the method is self-contained.
@plowman
Copy link
Contributor

plowman commented Jul 28, 2022

I put up a PR, #463, which should at least fix this specific problem. It seems there are some cobwebs on the CI for this project, however, so this may require some maintainer love to fix the tests and merge.

rycus86 added a commit to rycus86/prometheus_flask_exporter that referenced this issue Aug 2, 2022
The restplus example was impacted by python-restx/flask-restx#460
@ptmcg
Copy link

ptmcg commented Aug 2, 2022

Now more urgent, with the release of Flask 2.2.0 and its associated update to latest werkzeug.

@takshch
Copy link

takshch commented Aug 5, 2022

This error wasted my 30 minutes

It really needs to be fixed asap!

@jpiwek
Copy link

jpiwek commented Aug 5, 2022

have the same issue... also waiting for a fix.

@rootVIII
Copy link

Having this issue as well.... I personally don't mind downgrading, but our pipeline uses a codescanner that will not allow older Werkzeug due to an open CVE

@jpiwek
Copy link

jpiwek commented Aug 15, 2022

Hi folks,

I am also waiting for a patch:
today I tried with these Py Package versions:
flask==2.2.2
flask_restx=0.5.1
werkzeug==2.2.2
flask-login==0.6.2

It seems like flask_restx.swagger.py makes issues as werkzeug.routing.rules.py has changed. It doesn't support parse_rule function anymore. Instead there is a new _parse_rule function inside the Rule Class.
I had no time to implement the new Werkzeug Rule API into Flask-RestX. However I created two patch files as an interim solution to get everything running again and to make swagger HTML accessible!
Please let me know if it works for you.

20220815_flask_restx_patches.tar.gz

@Ryu-CZ
Copy link
Contributor

Ryu-CZ commented Aug 26, 2022

Hi unrest folk,
because flask-restx is still not compatible with werkzeug I created small monkey patch https://github.com/Ryu-CZ/restx-monkey I am using it at work on company servers, so far so goo. I hope it helps as temporal quick solution for anyone. Enjoy 👍

PS: It also patches flask_restx.Api soon to be incompatible lazy swagger doc routes binding in case you bind Api with flask.Blueprint first, and register Blueprint into flask app instance flask.Flask later.

ziirish added a commit that referenced this issue Sep 13, 2022
@kannanprasanna
Copy link

@ziirish , will this fix be released as a new version soon? - Thanks

@amotl
Copy link

amotl commented Sep 19, 2022

@kannanprasanna: See #474.

reimer-atb added a commit to eclipse-opensmartclide/smartclide-service-discovery-poc that referenced this issue Sep 29, 2022
reimer-atb added a commit to eclipse-opensmartclide/smartclide-service-discovery-poc that referenced this issue Sep 29, 2022
cedricbonhomme added a commit to NC3-LU/MOSP that referenced this issue Oct 10, 2022
AntiCompositeNumber added a commit to AntiCompositeNumber/signatures that referenced this issue Oct 26, 2022
AntiCompositeNumber added a commit to AntiCompositeNumber/signatures that referenced this issue Oct 26, 2022
@zogzog
Copy link

zogzog commented Oct 26, 2022

So it looks fixed in the sources. Any plan to release a 0.5.2 on pypi ?
Thanks.

schlotze pushed a commit to eclipse-opensmartclide/smartclide-service-discovery-poc that referenced this issue Nov 16, 2022
* only add Authorization header if token exists

This patch makes the database config "token" optional.
Users can either set it to an empty string or omit the token completely.
This is useful for DB-APIs that do not require authentication, and
therefore no token.

* pin dependency werkzeug to version 2.1.2

to workaround python-restx/flask-restx#460

* add git ignore file

build output and caches can be ignored by git

* downgrade werkzeug even further to 2.0.*

as suggested in python-restx/flask-restx#460 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests