diff --git a/discovery-provider/src/tasks/entity_manager/user.py b/discovery-provider/src/tasks/entity_manager/user.py index f9bb7e6cb0b..3aee7d92026 100644 --- a/discovery-provider/src/tasks/entity_manager/user.py +++ b/discovery-provider/src/tasks/entity_manager/user.py @@ -67,14 +67,15 @@ def validate_user_tx(params: ManageEntityParameters): def validate_user_metadata(session, user_record: User, user_metadata: Dict): # If the user's handle is not set, validate that it is unique if not user_record.handle: + handle_lower = user_metadata["handle"].lower() user_handle_exists = session.query( - session.query(User).filter(User.handle == user_metadata["handle"]).exists() + session.query(User).filter(User.handle_lc == handle_lower).exists() ).scalar() if user_handle_exists: # Invalid user handle - should not continue to save... raise Exception(f"User handle {user_metadata['handle']} already exists") user_record.handle = user_metadata["handle"] - user_record.handle_lc = user_metadata["handle"].lower() + user_record.handle_lc = handle_lower # If an artist pick track id is specified, validate that it is a valid track id if (