Replies: 3 comments
-
We are stuck with this issue. Not sure if it is for my local environment or something else. Can someone have a look ? |
Beta Was this translation helpful? Give feedback.
-
The safe argument was never deprecated or something. It's still there in the code, and the register endpoint definitely works. Probably something (a LLM?) changed code in your local environment. I would suggest you reinstall your dependencies from scratch. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the response, I will need to recheck the python dependencies again then, will get back.. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Subject: TypeError: create() unexpected keyword argument 'safe' in register router with fastapi-users==14.0.1
Description:
When using fastapi-users==14.0.1 in conjunction with fastapi-users-db-sqlalchemy (specifically with SQLAlchemyUserDatabase), attempting to use the /register endpoint results in a TypeError. The specific error message is:
TypeError: SQLAlchemyUserDatabase.create() got an unexpected keyword argument 'safe'
Problematic Code Location:
Upon investigation, the issue stems from the call to user_manager.create() within the register endpoint handler, located in the fastapi_users/router/register.py file. The line in question is:
Python
created_user = await user_manager.create(
user_create, safe=True, request=request
)
Context:
The safe parameter was deprecated and subsequently removed from the BaseUserManager.create method signature (and by extension, from database adapters like SQLAlchemyUserDatabase) starting from fastapi-users version 13.0.0.
However, the register.py router file in fastapi-users version 14.0.1 (and also observed on the master branch at the time of this report) still explicitly passes safe=True when calling user_manager.create. This creates an incompatibility with fastapi-users-db-sqlalchemy (e.g., version 7.0.0), which no longer expects this argument.
Versions:
Expected Behavior:
The /register endpoint should function correctly without TypeErrors. The user_manager.create() call within fastapi_users/router/register.py should omit the safe=True argument, aligning with the updated BaseUserManager.create signature in fastapi-users v13+ and its database adapters.
Actual Behavior:
The TypeError occurs due to the unexpected safe=True keyword argument being passed, preventing successful user registration.
Steps to Reproduce:
Beta Was this translation helpful? Give feedback.
All reactions