AssertionError in User Management ticket

I am getting the following error on running the user management ticket for add_user method and db.users.createIndex({“email” : 1},{unique: true}) does not seem to help

Hi @Arushi_29302,

You do not need to create any index on the collection unless the lab explicitly asks to add. For the issue, try checking if user exists before creating a user.


I have tried the insert_one() and update_one() with upsert value true as well. Then upon visit the forum discussion related to the error I am getting I got to know about the create index method. Please let me know how to proceed.

Warm Regards,

Hello Again,

Shall use the following code snippet in add_user() method:

“name”: name,
“email”: email,
“password”: hashedpw
if db.users.find_one({“email”:email}) is None:

This should work. Otherwise you can use try catch block as well.


Hello Kanika,

It is still throwing the same error.
I even tried the following:

info={“name”: name,“email”: email,“password”: hashedpw}
if get_user(email) is None:

where get_user(email) is a method implemented in to find document in users collection by email and it is used in other methods as shown as such.

Sent you a message :slight_smile:


I am also getting problem in User-Management. Can anybody give me the actual codes which i will execute. From last 4hour i am in this trouble…

That would completely defeat the purpose of taking a course to learn.

Share the problem you have and we will help. A screenshot is best as we see the whole context.