pallets-eco / flask-session

Server side session extension for Flask
https://flask-session.readthedocs.io
BSD 3-Clause "New" or "Revised" License
490 stars 236 forks source link

Add support for werkzeug-3.0.0 #189

Closed hluk closed 7 months ago

hluk commented 9 months ago

...and in turn Flask 3.0.0 which requires that version.

Werkzeug removed support for passing bytes where str is expected.

See: https://github.com/pallets/werkzeug/commit/5ff0a573f4b78d9724f1f063fb058fd6bc76b24d

camAtGitHub commented 9 months ago

Ahh you beat me to it.

For all the people searching for this bug, this is the stacktrace:

Traceback (most recent call last): ```python Traceback (most recent call last): File "/app/venv/lib64/python3.9/site-packages/flask/app.py", line 1478, in __call__ return self.wsgi_app(environ, start_response) File "/app/venv/lib64/python3.9/site-packages/flask/app.py", line 1458, in wsgi_app response = self.handle_exception(e) File "/app/venv/lib64/python3.9/site-packages/flask/app.py", line 1455, in wsgi_app response = self.full_dispatch_request() File "/app/venv/lib64/python3.9/site-packages/flask/app.py", line 870, in full_dispatch_request return self.finalize_request(rv) File "/app/venv/lib64/python3.9/site-packages/flask/app.py", line 891, in finalize_request response = self.process_response(response) File "/app/venv/lib64/python3.9/site-packages/flask/app.py", line 1270, in process_response self.session_interface.save_session(self, ctx.session, response) ```
  File "/app/venv/lib64/python3.9/site-packages/flask_session/sessions.py", line 362, in save_session
    response.set_cookie(app.config["SESSION_COOKIE_NAME"], session_id,
  File "/app/venv/lib64/python3.9/site-packages/werkzeug/sansio/response.py", line 224, in set_cookie
    dump_cookie(
  File "/app/venv/lib64/python3.9/site-packages/werkzeug/http.py", line 1304, in dump_cookie
    if not _cookie_no_quote_re.fullmatch(value):
TypeError: cannot use a string pattern on a bytes-like object

Which is breaking the functionality of SESSION_USE_SIGNER=True

saschapapini commented 8 months ago

Hi everyone, is it possible to know when this pull will be accepted and a new version will be released?

saschapapini commented 8 months ago

Hi everyone, are there any updates?

Hi everyone, is it possible to know when this pull will be accepted and a new version will be released?

Ehckme commented 7 months ago

Hi to all. A quick check in for any updates... or any solution?

Ehckme commented 7 months ago

Hello good developers, are there any changes or updates performed on this specific bug?

Lxstr commented 7 months ago

Hi @hluk thanks for the issue and thanks everyone else for the reminders. @hluk I seem unable to push to your PR branch. Are you able to manually add me as a contributer perhaps?

hluk commented 7 months ago

Hi @hluk thanks for the issue and thanks everyone else for the reminders. @hluk I seem unable to push to your PR branch. Are you able to manually add me as a contributer perhaps?

Sorry, I might have missed some contribution guidelines: Why do you need to push to my fork?

Is there anything you want me to fix in the PR?

Lxstr commented 7 months ago

No you didn't miss anything, I just wanted to take your implementation a step further and clean up some of the original logic.

Normally maintainers can push to a fork (can see it's checked on the right sidebar) but I think it's an issue with my maintainer permissions in this case.

I've put my additions in (https://github.com/Lxstr/flask-session/tree/werkzeug-3) for now. Let me know your thoughts. Also waiting from input from the team.

Ps. I'm thinking we will merge Black formatting PR before this one, hence the formatting additions.

hluk commented 7 months ago

I've put my additions in (https://github.com/Lxstr/flask-session/tree/werkzeug-3) for now. Let me know your thoughts. Also waiting from input from the team.

I've included your changes in this PR.

ThiefMaster commented 7 months ago

just a suggestion for future prs: using merge commits to bring a PR branch up to date results in a quite hard to read git log. it's much better to rebase a PR's branch or do a squash merge if the branch contains merge commits and there's no need to keep individual commits from the PR

neurino commented 6 months ago

Hello, any update on this? Still getting TypeError: cannot use a string pattern on a bytes-like object today.

saschapapini commented 5 months ago

Hi everyone, are there any updates?

Lxstr commented 5 months ago

Hi all. A pre-release is imminent, sorry for the delay I've had to go through a lot of historical issues and PRs. If you are able to test the code on the current Development branch and give any feedback that would be appreciated

juliocepar commented 5 months ago

Hi @Lxstr. Do you have an ETA for the next release with this fix?

ghawes85 commented 5 months ago

Hi all. A pre-release is imminent, sorry for the delay I've had to go through a lot of historical issues and PRs. If you are able to test the code on the current Development branch and give any feedback that would be appreciated

Hi @Lxstr, I am using your development branch on one of my projects, and seems to be stable for my use cases. I Am using Flask==3.0.0 and Werkzeug==3.0.1.

Looking forward to the pre-release. Thanks for the work on this!

Lxstr commented 5 months ago

Hi all 0.6.0rc1 is now available. Please try in development and let me know if there is any issues.

neurino commented 5 months ago

Using pip-compile it pulled in flask-session==0.6.0 and it seems to work — at least no more TypeError: cannot use a string pattern on a bytes-like object on startup

flask==3.0.1
    # via
    #   -r requirements.in
    #   flask-babel
    #   flask-login
    #   flask-principal
    #   flask-session
flask-babel==4.0.0
    # via -r requirements.in
flask-login==0.6.3
    # via -r requirements.in
flask-principal==0.4.0
    # via -r requirements.in
flask-session==0.6.0
    # via -r requirements.in
werkzeug==3.0.1
    # via
    #   flask
    #   flask-login