You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "VladaZakharova (via GitHub)" <gi...@apache.org> on 2026/07/17 11:46:01 UTC

Re: [PR] Displaying first_name+last_name or email in "Audit Log" on DAG details page [airflow]

VladaZakharova commented on code in PR #68833:
URL: https://github.com/apache/airflow/pull/68833#discussion_r3602867449


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/event_logs.py:
##########
@@ -54,6 +56,65 @@
 event_logs_router = AirflowRouter(tags=["Event Log"], prefix="/eventLogs")
 
 
+def _get_user_display_name(user) -> str:
+    """Return the most readable identity label available for audit logs."""
+    first_name = (getattr(user, "first_name", None) or "").strip()
+    last_name = (getattr(user, "last_name", None) or "").strip()
+    email = (getattr(user, "email", None) or "").strip()
+    username = (getattr(user, "username", None) or "").strip()
+
+    if first_name and last_name and last_name != "-":
+        return f"{first_name} {last_name}"
+    if email:
+        return email
+    return username
+
+
+def _get_owner_display_names_by_owner(owners: Iterable[str | None], session: Session) -> dict[str, str]:
+    owner_values = {owner for owner in owners if owner}
+    if not owner_values:
+        return {}
+
+    try:
+        from airflow.providers.fab.auth_manager.models import User
+    except ImportError:
+        return {}

Review Comment:
   thanks, i have updated the code so it uses BaseUser and user.get_name().



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org