ChickenBenny commented on code in PR #77234:
URL: https://github.com/apache/airflow/pull/77234#discussion_r4624827116
##########
providers/fab/src/airflow/providers/fab/auth_manager/api_fastapi/services/users.py:
##########
@@ -176,6 +162,24 @@ def update_user(cls, username: str, body: UserPatchBody,
update_mask: str | None
else:
fields_to_update = all_fields
+ # The lookups can return this user itself, e.g. usernames match
case-insensitively,
+ # so only a different user is a conflict.
+ if "username" in fields_to_update and body.username is not None:
+ existing = security_manager.find_user(username=body.username)
+ if existing is not None and existing.id != user.id:
+ raise HTTPException(
+ status_code=status.HTTP_409_CONFLICT,
+ detail=f"The username `{body.username}` already exists",
+ )
+
+ if "email" in fields_to_update and body.email is not None:
Review Comment:
Done, both checks now run in one loop.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]