Vasu-Madaan commented on code in PR #76812:
URL: https://github.com/apache/airflow/pull/76812#discussion_r4561403118


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/ui/auth.py:
##########
@@ -66,6 +66,7 @@ def get_current_user_info(
     return AuthenticatedMeResponse(
         id=user.get_id(),
         username=user.get_name(),
+        display_name=user.get_display_name(),

Review Comment:
   Thanks for the review! 
   BaseUser.get_display_name() is declared to return a str (def 
get_display_name(self) -> str). Every auth manager in this repo (Simple, FAB, 
Keycloak, AWS) returns a string from it. However, Python doesn't enforce return 
type hints at runtime, so a custom auth manager that overrides 
get_display_name() could still return None by mistake. 
   
   To prevent that, the endpoint now uses user.get_display_name() or 
user.get_name(). If get_display_name() returns None or an empty string, the 
endpoint falls back to the value of get_name() (the username) instead of 
failing.
   
   I also added a test, test_display_name_falls_back_to_username, that makes 
get_display_name() return None and checks that the endpoint still returns the 
username.



-- 
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]

Reply via email to