This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
dynamic='lazy' in SQLAlchemy relationship causes FastAPI to stack overflow #3886
Comments
Can you provide a minimal working example? |
models/student.py
routers/student.py
schemas/notes.py
models/note.py
I think these are all the relevant files. |
Any updates? Any relationship where lazy='dynamic' is defined creates a stack overflow in FastAPI. |
Maybe this helps? #194 🤔 |
Thank you, but |
Bump. We really need to solve this before we can continue our project. @Kludex - do you need any additional information from us? |
Another example: models/user.py:
schemas/users.py:
models/notification.py:
schemas/notifications.py:
routers/users.py:
This works like expected. However, when we want to filter to only show the unread notifications to the user, things start to act crazy. We make the following changes: models/user.py:
routers/users.py:
This causes the following error:
That is weird - nothing should be changed in the output (this user only has unread notifications). When we remove the response model to check the output, we get the stack overflow as posted in this issue. Are we doing something wrong? Is FastAPI doing something wrong? Is SQLAlchemy doing something wrong? |
I don't think the "dynamic" strategy can be applied, I think I've faced the same issue some time ago, but I need to recheck the If you want help, you should probably add a proper minimal working example i.e. that ppl can copy/paste/clone and just run. In any case, you can check if other |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
First Check
Commit to Help
Example Code
Description
Hi,
I hope you are all well. I'm using FastAPI in combination with SQLAlchemy, so I'm not really sure if I should post this there or here, but from the logs it seems that FastAPI is causing the stack overflow.
I have the following defined in my Student-model:
And this is my function in the router which when I run it causes the stack overflow:
This is the error that is being generated upon running the function above:
Once again, not sure if it's FastAPI, but it seems that way. Thanks in advance!
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.68.1
Python Version
Python 3.9.7
Additional Context
No response
The text was updated successfully, but these errors were encountered: