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

'_SQLAlchemyState' object has no attribute 'session' #262

Closed
Nilster opened this issue Apr 17, 2023 · 3 comments
Closed

'_SQLAlchemyState' object has no attribute 'session' #262

Nilster opened this issue Apr 17, 2023 · 3 comments

Comments

@Nilster
Copy link

Nilster commented Apr 17, 2023

Hi there, I am noticing an issue with flask-marshmallow==0.15.0.

File "/src/manage.py", line 5, in
app = create_app()
File "/src/themis/app.py", line 69, in create_app
initialise_extensions(app)
File "/src/themis/app.py", line 79, in initialise_extensions
ma.init_app(app)
File "/usr/local/lib/python3.10/site-packages/flask_marshmallow/init.py", line 116, in init_app
self.SQLAlchemySchema.OPTIONS_CLASS.session = db.session
AttributeError: '_SQLAlchemyState' object has no attribute 'session'

It is working fine with flask-marshmallow==0.14.0 but since launch of 0.15.0, our build pipeline has started to fail because of this issue. Here is trimmed down list of modules for the trio of flask, marshmallow and sqlalchemy

Flask==2.2.2
Flask-SQLAlchemy==2.5.1
psycopg2-binary==2.9.3
itsdangerous==2.1.2
marshmallow==3.19.0
marshmallow-sqlalchemy==0.28.1
SQLAlchemy==1.4.46
flask-migrate==4.0.4

Let me know if you need any more info to recreate the issue.

Thanks.

@sirosen
Copy link
Collaborator

sirosen commented Apr 17, 2023

Hi there!

The latest version of flask-marshmallow does not support flask-sqlalchemy version 2.5.1; that's what causes this issue. You'll need to coordinate any update to the last flask-marshmallow with flask-sqlalchemy version 3, or pin back your version of flask-marshmallow to v0.14.0.

I'm also going to take a look at adding a feature to detect and emit a more appropriate error message in this case, as you're not the first to encounter this.

@Nilster
Copy link
Author

Nilster commented Apr 18, 2023

Ok, thanks for the response.

@rbjones92
Copy link

Solved my question, thank you sironsen

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

4 participants